Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I properly read out spin buttons in pyGTK?
    primarykey
    data
    text
    <p>For a small timer app I want to write a GTK interface where I can set the desired time. Here is a picture of the interface:</p> <p><img src="https://i.stack.imgur.com/shq8D.png" alt="alt text"></p> <p>However, I am having trouble reading out the fields of the spin buttons. My envisaged procedure for this is the following:</p> <ol> <li>Read out the buttons using methods for each button</li> </ol> <p>Here is one of the methods that does this:</p> <pre><code># Get the fields of the spinbuttons def get_seconds(self, widget, spin): self.rSeconds = spin.get_value_as_int() </code></pre> <p>It is then called like this:</p> <pre><code> button = gtk.Button("Start") button.connect("clicked", self.get_seconds, spinnerS) </code></pre> <ol start="2"> <li>Create a timer object with the data from the buttons</li> </ol> <p>This is planned to be accomplished using this method:</p> <pre><code> # Create the timer object ... def prepare_timer(self, widget, hours, minutes, seconds, title, text): self.timer = eggTimer(hours, minutes, seconds, title, text) </code></pre> <p>Which is called here:</p> <pre><code>button.connect("clicked", self.prepare_timer, self.rHours, self.rMinutes, self.rSeconds, "some title", "some text") </code></pre> <p>Unfortunately, when running the script I get the following error message:</p> <pre><code>Traceback (most recent call last): File "GTKInterface.py", line 140, in &lt;module&gt; SpinButtonExample() File "GTKInterface.py", line 126, in __init__ button.connect("clicked", self.prepare_timer, self.rHours, self.rMinutes, self.rSeconds, "Title", "Text") AttributeError: SpinButtonExample instance has no attribute 'rSeconds' </code></pre> <p>To check whether there really is no instance of that variable, I programmed a short method to print it:</p> <pre><code> def returnS(self, widget): print self.rSeconds </code></pre> <p>And surprisingly this method <em>can</em> "see" self.rSeconds. This makes me wonder what determines the visibility of the variable. What am I doing wrong to read this out?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload