glenn has asked for the wisdom of the Perl Monks concerning the following question:

So I am trying to add a GUI to the program that stresses servers. I have the basic skeleton program written but i am stuck at the most important part, the GUI control. This is my first 'real' GUI and i'm open to LOTS of suggestions. Sorry for the long code but it works (windows)! I had this quazi working but I later found that the updates were just going on top of the original row and ran out of allowed elements. So here is what the program does:

Thread 1: Discovers systems and adds them to a queue to be processed
Thread 2: Finds details about the discovered systems and creates the XML structure for that system
Thread 3: Starts threaded tests from a queue populated by the GUI

GUI: Addes a row of info/buttons from Thread 2's queue. User can update the system info (real life must enter serial number before starting) and adjust test parameters. User will 'start' the system.

Problems:
When the ctr_1 button is clicked it should update the system status, disable user input for that system, start the test, not too hard but need the correct way. ctr_1 and 2 buttons change values/state on this action. Later user can pause/cancel(stop) a test.

#hardest problem
When a test is complete it needs to update the GUI with the progress. If the system state changes from 'running' (executing tests) to 'paused' or 'stopped' the ctr_1 and 2 buttons should change state/values to reflect this change.

I cannot save the row of GUI objects to the system's XML data. Making updating difficult.

I hope there is somebody that understands what i am trying to do... this does work when it was done wrong!
perl 5, version 12, subversion 4 (v5.12.4) built for MSWin32-x64-multi-thread

Replies are listed 'Best First'.
Re: Advanced GUI with threads
by glenn (Scribe) on Sep 10, 2013 at 15:50 UTC
    UPDATE:

    So I have been reworking the code and have removed as much as possible. I think I now have it written correctly but the GUI is not updating when variables changes label(-textvariable...). I was hoping someone could take a look at the revised code and tell me where the problem is, Thanks.

    When the program starts a system is discovered and the IP passed to a process which adds supporting info in an XML structure. That info is passed to the GUI to add a row for that system. When the user presses start the system status, job progress, system state values in the GUI do not update even though they have been changed. I have added $mainwindow->update(); in several places hoping that would help but it has not.

      If you want anyone to even consider you problem, you'll need to reproduce that problem with a piece of working, runnable code that is 20 or 30 lines ling at most.

      You appear to creating a thread for which your code contains no subroutine.:

      threads->create("executejob")->detach();

      A quick scan down your pile of code doesn't discover any subroutine called executejob. That, combined with the absence of strict & warnings and the shear size of you code mans I cannot be bothered to even download.

      You want help, make some effort.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        FWIW sub executejob { is in there ... line 102 of 445 :)

        Thank you for taking a look. 'Executejob' is the second sub under '#THREADS' at line 102. I will post a hard coded example to simplify as much as i can but the passing and retrieving from threads is going to remain the real issue. I am thinking of using a 2d global array for storing some objects but have not gone down that path yet.
        Plz try latest code, w/strict and warnings. Not much more can be removed or simplified. Thank you for taking a look.
Re: Advanced GUI with threads
by glenn (Scribe) on Sep 13, 2013 at 13:44 UTC

    I dont know if i can remove much more... most is just setup. Everything of concern is in the GUI. The label text is a variable that points to that systems reference in the global XML structure. Those should remain true always, anyway to check? Anyway to get all info about GUI??? When the test is done the global XML is updated which should update the labels via the variables. I am even running $mainwindow->update(); for good measure.

    added strict & warnings and defined undefined variables from original code. Error free, except the things that didn't work before which I am asking for help on.

Re: Advanced GUI with threads
by glenn (Scribe) on Nov 13, 2013 at 19:55 UTC
    Ok got it working, here it is full bore: