Jump to content

Dialogue Progress Bar


---
 Share

Recommended Posts

Good Morning all, 

I have a question and hoping for some help with said question if it is possible. 

I have a script that imports multiple features into the software and then adds various other elements to each feature dependant on an identifier in the import CSV. I noticed in the dialogue creator you can create a progress bar. 

My question is, could I somehow set this dialogue bar up so that it slowly progresses across as it imports the elements from the CSV file? 

If possible how do I go about this? I've had a little play to try and figure out how to set the code up, or when to input the details for the progress bar but I would need it to take a total feature count from the CSV then slowly progress as the software imports features (sometimes in excess of 2000 features). 

If anyone can help, has an example or can point me in the right direction that would be greatly appreciated. 

Link to comment
Share on other sites

Hello,

here is a small example:

# -*- coding: utf-8 -*-

import gom

file = "path to a csv-File"

DIALOG=gom.script.sys.create_user_defined_dialog (dialog={
    "content": [
        [
            {
                "columns": 2,
                "maximum": 100,
                "minimum": 0,
                "mode": "manual",
                "name": "progressbar_file",
                "parts": 1,
                "rows": 1,
                "step": 0,
                "text": "step",
                "tooltip": {
                    "id": "",
                    "text": "",
                    "translatable": True
                },
                "type": "display::progressbar",
                "value": 0
            },
            {
            }
        ]
    ],
    "control": {
        "id": "Empty"
    },
    "embedding": "always_toplevel",
    "position": "automatic",
    "size": {
        "height": 79,
        "width": 125
    },
    "sizemode": "fixed",
    "style": "",
    "title": {
        "id": "",
        "text": "Fortschritt",
        "translatable": True
    }
})

def dialog_event_handler (widget):
	pass

DIALOG.handler = dialog_event_handler

gom.script.sys.open_user_defined_dialog (dialog=DIALOG)


f1 = open(file, 'r')

DIALOG.progressbar_file.maximum = sum(1 for line in open(file))

c = 0
for line in f1:
	c += 1
	time.sleep(0.1)
	DIALOG.progressbar_file.value = c
f1.close()

gom.script.sys.close_user_defined_dialog (dialog=DIALOG)

 

Regards Marcus

Link to comment
Share on other sites

 Share

×
×
  • Create New...