how to simple connect a button with a progressbar

Discussion in 'Python' started by macstar, Sep 11, 2014.

  1. macstar

    macstar

    Joined:
    Sep 11, 2014
    Messages:
    1
    Likes Received:
    0
    i have a bit experience with python and glade, and so far i can successfully create buttons, boxes, etc. and i can make each button or checkbox to output a print command.

    now the thing i wanna to achieve is that i have - to make it easier - a simple file where i have 1 button and 1 progressbar.
    now i wanna make the progressbar either pulsing (should be easier afaik) or progressing till the thread i run is completed.
    for start i would be happy if the progressbar just pulses when i do a button click.

    however: i have tried the whole day and it just seems to be impossible.
    google did not help:

    so here is my simple code:
    Code (Text):

    from gi.repository import Gtk
    import subprocess

    class Handler:
      def on_window1_delete_event(self, *args):
      Gtk.main_quit(*args)

      def on_button1_clicked(self, button):
      print("Hello World!")

    builder = Gtk.Builder()
    builder.add_from_file("progress2.glade")
    builder.connect_signals(Handler())

    window = builder.get_object("window1")
    progressbar = builder.get_object("progressbar1")
    window.show_all()

    Gtk.main()
     
    now i need to somehow get the progressbar.
    if i make it like this:
    Code (Text):
    from gi.repository import Gtk
    import subprocess

    class Handler:
        def on_window1_delete_event(self, *args):
            Gtk.main_quit(*args)

        def on_button1_clicked(self, button):
            print("Hello World!")
        self.progressbar.pulse()
    builder = Gtk.Builder()
    builder.add_from_file("progress2.glade")
    builder.connect_signals(Handler())

    window = builder.get_object("window1")
    progressbar = builder.get_object("progressbar1")
    window.show_all()

    Gtk.main()
    i get the error:
    making it like this:
    Code (Text):
    from gi.repository import Gtk
    import subprocess

    class Handler:
        def on_window1_delete_event(self, *args):
            Gtk.main_quit(*args)

        def on_button1_clicked(self, button):
            print("Hello World!")
        progressbar.pulse()
    builder = Gtk.Builder()
    builder.add_from_file("progress2.glade")
    builder.connect_signals(Handler())

    window = builder.get_object("window1")
    progressbar = builder.get_object("progressbar1")
    window.show_all()

    Gtk.main()
    makes the progressbar only pulsing a small step each time i click the button.
    i want to have it pulsing endlessly if i click the button only once.
    how?

    i suspect we would need to end a kind of loop right?
     
    macstar, Sep 11, 2014
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Maka Sili
    Replies:
    0
    Views:
    745
    Maka Sili
    Aug 25, 2004
  2. Maka Sili
    Replies:
    0
    Views:
    608
    Maka Sili
    Aug 25, 2004
  3. Otis Mukinfus
    Replies:
    3
    Views:
    1,288
    Juan T. Llibre
    Jul 8, 2005
  4. kishore@novelteam.com
    Replies:
    3
    Views:
    42,582
    Roedy Green
    Nov 16, 2005
  5. Nilton Volpato
    Replies:
    0
    Views:
    577
    Nilton Volpato
    May 8, 2006
  6. Nilton Volpato
    Replies:
    0
    Views:
    678
    Nilton Volpato
    May 7, 2006
  7. zhangxiaoyu912@gmail.com
    Replies:
    2
    Views:
    659
    usenet@DavidFilmer.com
    Jul 18, 2007
  8. Mohsen Pahlevanzadeh

    Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    3
    Views:
    498
    Mohsen Pahlevanzadeh
    Sep 18, 2013
Loading...