Editing Russ Python Tips and Techniques

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 262: Line 262:
 
Tkinker wants to own the processing of the application.  If you make a button start a long running operation then the GUI blocks and becomes unresponsive.  So you need some sort of threading.  Here are some tips.
 
Tkinker wants to own the processing of the application.  If you make a button start a long running operation then the GUI blocks and becomes unresponsive.  So you need some sort of threading.  Here are some tips.
  
== Row and Column IX  ==
+
=== Polling withing Tkinker ===  
 
 
I mostly use the grid layout.  In this you will see "column = 3, row = 5" and the like, in the next use often one of the indices is incremented.  So a way to do this with less typing ( assuming copy and paste ) is:
 
 
 
<pre>
 
        ix_row    = 0
 
        ix_col    = 0
 
        rowspan    = 1
 
        widget_var  = IntVar()
 
        a_widget    = Checkbutton( a_frame, text="Live Graph", variable = widget_var, width = 10, anchor="w" )
 
        a_widget.config( command = self.controller.cb_graph_live )
 
        a_widget.config( borderwidth = 5, relief = RAISED,  )
 
        a_widget.grid( row = ix_row, column = ix_col, rowspan = rowspan, sticky = E + W + N + S )
 
        self.graph_live_var  = widget_var
 
 
 
        # button to save graph data to csv file 
 
        ix_col +=  1
 
        a_widget = Button( a_frame , width = 10, height = 1, text = "Save CSV" )
 
        a_widget.config( command = self.controller.cb_csv )
 
        a_widget.grid( row = ix_row, column = ix_col, rowspan = rowspan, sticky = E + W + N + S )
 
       
 
       
 
        ix_col  +=  1
 
        ......
 
</pre>
 
 
 
 
 
 
 
  
=== Polling withing Tkinker  ===
 
 
You can poll in the Tkinter event loop and call any function ( no arguments I think ) using a Tkinter function.  Use this to run something short.  You can only run it once this way.
 
You can poll in the Tkinter event loop and call any function ( no arguments I think ) using a Tkinter function.  Use this to run something short.  You can only run it once this way.
 
<pre>
 
<pre>

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)