how to simple connect a button with a progressbar

Joined
Sep 11, 2014
Messages
1
Reaction score
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:
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:
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:
File "test1.py", line 10, in on_button1_clicked
self.progressbar.pulse()
AttributeError: Handler instance has no attribute 'progressbar'

making it like this:
Code:
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?
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top