I suspect this is a lack of understanding the underlying issue, but my google-fu is failing me.

I am in the process of writing a Tkx based program. At one point in this program I have to iterate through a list of files to do stuff with them. I want to provide the user visual feedback about how far along the list I am when I am iterating through the files.

The thing is that when I attempt to update my progress bar inside the iteration loop, the gui doesn't change.

I suspect the problem is a threading issue, where I'm not setting up my UI in a separate thread or something to that effect. Thing is that, if that is the problem, I can't find any documentation or howto for dummies to do it.

This is not complete code, but I think it's enough to get the idea of what I'm doing across.

use strict; use XML::Twig; use Tkx; use Net::FTP; use Thread; # needed for frames and grids to work. Tkx::package_require("tile"); # main window and properties my $main_window = Tkx::widget->new("."); my $grid = $main_window->new_ttk__frame( # left going clockwise -padding => "1 1 1 1", -borderwidth => 5, ); $grid->g_grid( -column => 0, -row => 0, -sticky => "nsew", ); $main_window->g_grid_columnconfigure( 0, -weight => 1, ); $main_window->g_grid_rowconfigure( 0, -weight => 1, ); &init(); Tkx::MainLoop(); sub init { # Progress bar... my $progress = 0; my $overall_progress_bar = $grid->new_ttk__progressbar( -orient => "horizontal", -mode => "determinate", -length => "200", -maximum => $file_count, -value => $progress, ); # buttons... my $publish = $grid->new_button( -text => "Publish", -command => sub { # now for heavy lifting... # get a list of files to be FTPed. my @ftp_list = &get_ftp_list($chosen_dir); # get a count of how many files I'm FTPing. my $file_count = scalar(@ftp_list); # get the media ID of the capture my $media_id = &check_media_id($chosen_dir); $overall_progress_bar->configure(-maximum => $file_count); # FTP the files, and count the number of successes. foreach my $i (@ftp_list) { $progress++; my $result = &ftp_file($i, $media_id, @profile_info); if ($result == 200) { $progress++; } } }, ); # layout section $choose_dir_label->g_grid(-column => 0, -row => 0, -columnspan => +2); $choose_dir->g_grid(-column => 2, -row => 0, -columnspan => 2); $chosen_dir_label->g_grid(-column => 0, -row => 1, -columnspan => +4); $profile_list_label->g_grid(-column => 0, -row => 2); $profile_list->g_grid(-column => 1, -row => 2, -columnspan => 2); $profile_info_label->g_grid(-column => 0, -row => 3, -columnspan = +> 4); $publish->g_grid(-column =>0, -row => 4); $modify_settings->g_grid(-column => 1, -row => 4); $reset->g_grid(-column => 2, -row => 4); $exit->g_grid(-column => 3, -row => 4); $overall_progress_bar->g_grid(-column => 0, -row => 5, -columnspan + => 4); &layout($grid); } sub layout { # Grabs a list of the current elements on the grid and adds 2px pa +dding # on every side of each element. foreach (Tkx::SplitList($_[0]->g_winfo_children)) { Tkx::grid_configure($_, -padx => 2, -pady => 2); } }

In reply to Tkx not updating progressbar as expected by jellisii2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.