473,503 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CheckButton -- modify "check state"

Hi,
How do for do a "select()" on a CheckButton in a menu (make with
add_checkbutton(....) )?
I can modify title, state, etc but not the "check state". :-(

Askari
Jul 18 '05 #1
2 3204
Askari wrote:
How do for do a "select()" on a CheckButton in a menu (make with
add_checkbutton(....) )?
I can modify title, state, etc but not the "check state". :-(


I have no clue what you're talking about: you have to at least
tell us what GUI toolkit you're using, and preferrably, show
a snippet of code.

--Irmen
Jul 18 '05 #2
Askari wrote:
Hi,
How do for do a "select()" on a CheckButton in a menu (make with
add_checkbutton(....) )?
I can modify title, state, etc but not the "check state". :-(


Assuming you're using Tkinter, the way to do it is to use the variable option
when you create the menu, and them modify the variable. Here is an example code:

--menu.py------------------------
from Tkinter import *

root = Tk()

## Create the menu bar
menuBar = Menu(root)
root.configure(menu=menuBar)

## Create the menu
menu = Menu(menuBar)
menuBar.add_cascade(label='Menu', menu=menu)

## Create the variable for the check button
myCheckVar = BooleanVar()

## Functions to check/uncheck/print the check state
def check(*whatever): myCheckVar.set(1)
def uncheck(*whatever): myCheckVar.set(0)
def print_option(*whatever): print myCheckVar.get()

## Entries in menu
menu.add_checkbutton(label='Option', variable=myCheckVar)
menu.add_command(label='Check', command=check)
menu.add_command(label='Uncheck', command=uncheck)
menu.add_command(label='Print', command=print_option)

root.mainloop()
---------------------------------

If you do not specify a command for the add_checkbutton, the default action is
to toggle the check state.

HTH
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3274
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
4
1142
by: C P | last post by:
I've seen references to using an out of process state server in cases where you need to maintain session state in a web server farm. I think SQL Server will be too slow to manage the state that I...
4
1187
by: Hrishi R | last post by:
Hi: The following ASP.NET code segment throws an "Object reference not set to an instance of an object" exception. ------------------ Public Sub Page_Load(Source As Object, E As EventArgs) ...
4
2065
by: jojoba | last post by:
hello all, does anyone know if, for a 2-state checkbox, you can use the "fill in" marker from the 3-state checkbox, instead of a checkmark i just like the look of the "fill-in" instead of the...
0
5662
by: Ismail Fatih Yıldırım | last post by:
I modified the RSACSPSample from MSDN to try out a simple commutative encryption model using RSA encryption but when i run the progrem the first encryption command works but during the second...
4
2641
by: louvino | last post by:
Hi, I have some links. When I click on one, a window opens but during the loading of this window, I would like the cursor is in state "wait" (using CSS : cursor : wait; ) Help me :-)
1
1584
by: Mikewill | last post by:
I need to fix my Moodle database and someone has told me that they "used their server's CPanel and the mySQL feature to "check" then "fix" his moodle database". I dont have a cpanel and was hoping...
10
1875
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but...
4
4981
by: frostbb | last post by:
I have a C# WinForms treeview with 20 or so 'level 0' nodes. My users will normally have 2 of the 'level 0' branches open down to a '5th level' selected node. The users will make updates to...
0
7203
marktang
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,...
0
7087
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...
0
7281
Oralloy
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,...
0
7334
jinu1996
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...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.