This is my code. I've tried a trillion different things. But basically what I want is the radiobuttons to appear. Select one and hit the okay button. Then the screen prints out the var of which button was selected (just to verify). And I want the whole program to wait and do nothing until this process is done. (What I'd want to do next is another radiobutton set, but I'm not there yet.)
Help! I've been researching this online all day today. I've found tons of posts with people with the same problems, but either the solutions weren't available, or made no sense to me.
Thank you very much in advance.
from Tkinter import *
master = Tk()
var = IntVar()
Radiobutton(master, text="One", variable=var, value=1).pack(anchor=W)
Radiobutton(master, text="Two", variable=var, value=2).pack(anchor=W)
Button(master, text='OK!',command=master.destroy).pack()
print "moo1 var = ",var
master.wait_variable
print "moo2 var = ",var
master.mainloop()
1 2593
I future, read posting or reply guidelines to learn how to use CODE tags so you post looks like this: -
from Tkinter import *
-
-
master = Tk()
-
-
var = IntVar()
-
var.set(1) # Set the defalt value to something
-
-
# I like to keep the instanciated button around in case I want to config it later
-
rb1 = Radiobutton(master, text="One", variable=var, value=1)
-
rb2 = Radiobutton(master, text="Two", variable=var, value=2)
-
rb1.pack(anchor=W)
-
rb2.pack(anchor=W)
-
-
#This should be what you needed.
-
def print_rb_state():
-
print "var = ", var.get()
-
-
Button(master, text='Print State!',command=print_rb_state).pack()
-
-
-
master.mainloop()
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Josh |
last post by:
Caution, newbie approaching...
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles...
|
by: Marcus Schneider |
last post by:
Sorry if this is an extremely stupid question:
I produced some Python modules with TKinter stuff and now I want to
use that from my main program. The windows have wuite some user
interaction....
|
by: max(01)* |
last post by:
hello.
the following code:
1 from Tkinter import *
2
3 class MiaApp:
4 def __init__(self, genitore):
5 self.mioGenitore = genitore
6 self.i = IntVar()
|
by: William Gill |
last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep
references to them in a 2 dimensional list ( rBtns ). It works
fine, and I can even make it so only one button per column can be...
|
by: William Gill |
last post by:
Working with tkinter, I have a createWidgets() method in a class.
Within createWidgets() I create several StringVars() and
assign them to the textvariable option of several widgets.
Effectively my...
|
by: Kevin Walzer |
last post by:
I'm trying to manage user preferences in a Tkinter application by
initializing some values that can then be configured from a GUI. The
values are set up as a dict, like so:
self.prefs= {...
|
by: Gigs_ |
last post by:
I'm working on tkinter paint program, mostly to learn tkinter canvas.
I have method which create buttons for oval, rectangle, line, polygon etc.
How to make oval button to be sunken when i click it...
|
by: seanacais |
last post by:
I'm trying to build an unknown number of repeating gui elements
dynamically so I need to store the variables in a list of
dictionaries. I understand that Scale "variable" name needs to be a...
|
by: Dream |
last post by:
The code create 2 windows. 2 radiobuttons are put on the second
window. A control variable "v" is binded to the 2 widgets.
But when I run the code, I found the control variable not binded...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |