Hi evryone!!
I' m very new not only to Python and Tkinter but to programing.
I'm a bit stuck here and would be grateful for some help.
I have 3 radio select buttons(see below) which I want to link to a pmw dialog with (apply and cancel options ) i.e. when I press enable btn dialog pops up and asks to confirm the my choice and if apply is selected then run my enable script if cancel then close the dialog. the same with the other radio buttons,if disable is selected then the same dialog appears and ask again to apply or cancel.
So far I got the buttons working and I get the different values printed on the console and if I uncoment the second ""choice=v.bloc k..."" this runs the script but at the moment from the "test" button. I don't need the buton and the console output instead I just want to be able to responce to the buttons via the dialog. I not sure if this makes any sence . this is some of my code so far.
thanks -
def myDialog(w):
-
dialog = Pmw.Dialog(root, buttons=('Apply', 'Cancel'),defaultbutton='Apply',title='ConfirmSelection',command=block_firewall())
-
return w
-
-
def block_firewall():
-
pipe_block = os.popen("./block-iptables", 'r')
-
-
def call():
-
choice = v.get()
-
#choice= v.block_firewall()
-
print '"Input %s "' % variant
-
#if choice
-
-
global v
-
v = IntVar()
-
-
radiobutton = Radiobutton(frame,text= "Enable", variable=v, value="1")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton = Radiobutton(frame,text= "Disable", variable=v, value="2")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton = Radiobutton(frame,text= "Block All", variable=v, value="3")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton.select()
-
-
test = Button(frame,text="Select",command=call)
-
test.pack()
4 3393 bartonc 6,596
Recognized Expert Expert
Hi evryone!!
I' m very new not only to Python and Tkinter but to programing.
I'm a bit stuck here and would be grateful for some help.
I have 3 radio select buttons(see below) which I want to link to a pmw dialog with (apply and cancel options ) i.e. when I press enable btn dialog pops up and asks to confirm the my choice and if apply is selected then run my enable script if cancel then close the dialog. the same with the other radio buttons,if disable is selected then the same dialog appears and ask again to apply or cancel.
So far I got the buttons working and I get the different values printed on the console and if I uncoment the second ""choice=v.bloc k..."" this runs the script but at the moment from the "test" button. I don't need the buton and the console output instead I just want to be able to responce to the buttons via the dialog. I not sure if this makes any sence . this is some of my code so far.
thanks -
def myDialog(w):
-
dialog = Pmw.Dialog(root, buttons=('Apply', 'Cancel'),defaultbutton='Apply',title='ConfirmSelection',command=block_firewall())
-
return w
-
-
def block_firewall():
-
pipe_block = os.popen("./block-iptables", 'r')
-
-
def call():
-
choice = v.get()
-
#choice= v.block_firewall()
-
print '"Input %s "' % variant
-
#if choice
-
-
global v
-
v = IntVar()
-
-
radiobutton = Radiobutton(frame,text= "Enable", variable=v, value="1")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton = Radiobutton(frame,text= "Disable", variable=v, value="2")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton = Radiobutton(frame,text= "Block All", variable=v, value="3")
-
radiobutton.pack(side=TOP,anchor=W)
-
-
radiobutton.select()
-
-
test = Button(frame,text="Select",command=call)
-
test.pack()
I was going to say that you should have a look at this thread and post back, but looking at your code, we'll want to work on your structure a bit.
In the mean time, have a look around, read some of the Posting Guidelines so that I won't have to add CODE tags for you.
Thanks for joining the Python Forum on TheScripts.com.
bartonc 6,596
Recognized Expert Expert
I was going to say that you should have a look at this thread and post back, but looking at your code, we'll want to work on your structure a bit.
In the mean time, have a look around, read some of the Posting Guidelines so that I won't have to add CODE tags for you.
Thanks for joining the Python Forum on TheScripts.com.
- from Tkinter import *
-
-
## The trick is to SUB CLASS the widget that you want to add fuctionality to ##
-
## I don't have PMW, but the idea is the same: a Tkinter.Frame is just a blank ##
-
## frame until you subclass it an give it something to do ## HAVE FUN
-
-
class MyFrame(Frame):
-
"""A subclass of Tkinter.Frame that has some radio buttons that share a StringVar."""
-
def __init__(self, root, *args, **kwargs):
-
Frame.__init__(self, root, *args, **kwargs)
-
-
# Create a variable to link the radio buttons
-
self.RadioButtonLink = RadioButtonLink = StringVar()
-
RadioButtonLink.set("On") # or whatever you want the default to be
-
-
# Create the radio buttons and arrange them on the frame
-
onRadio = Radiobutton(self, text="On", value="On", variable=RadioButtonLink)
-
onRadio.grid(row=0, column=0)
-
offRadio = Radiobutton(self, text="Off", value="Off", variable=RadioButtonLink)
-
offRadio.grid(row=0, column=1)
-
noneRadio = Radiobutton(self, text="None", value="None", variable=RadioButtonLink)
-
noneRadio.grid(row=0, column=2)
-
-
# This is just so we have a way to make an event #
-
selectButton = Button(self, text='Select')
-
selectButton.grid(row=1, column=0, columnspan=3)
-
selectButton.bind("<Button-1>", self.OnButton)
-
-
def OnButton(self, event):
-
"""Print the value of the selected radio button."""
-
print self.RadioButtonLink.get()
-
-
-
if __name__ == "__main__":
-
root = Tk()
-
-
frame = MyFrame(root)
-
frame.pack()
-
-
-
root.mainloop()
-
many thanks for the help guys , I got it working exactly as I wanted now tanks to you!!!
I hope one day I would be able to help others.
bartonc 6,596
Recognized Expert Expert
many thanks for the help guys , I got it working exactly as I wanted now tanks to you!!!
I hope one day I would be able to help others.
You are welcome. I LIKE your attitude.
Keep posting,
Barton
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Thomas Nücker |
last post by:
Hi!
I am creating a dialog-box within my application, using tkinter. The
problem is the following: After the dialogbox is started, the main
application window comes again to top and the dialogbox is covered by
the window of the main application and must be "fetched" again via the
taskbar to continue. Is there a way to "force" the dialogbox on top of
all other windows? (I'm using MSWindows and Python22)
The source of my dialogbox-class...
|
by: Stewart Midwinter |
last post by:
I would like to link the contents of three OptionMenu lists. When I select an
item from the first list (call it continents), the contents of the 2nd list
(call it countries) would update. And in turn the contents of the 3rd list (call
it states would be updated by a change in the 2nd list. If anyone can share a
recipe or some ideas, I'd be grateful!
Here's some sample code that displays three OptionMenus, but doesn't update the
list...
|
by: Rick |
last post by:
After being frustrated with this issue on several occasions I think I
found the secret sauce for solving the issue after reading a few
different messages about what others thought and trying a combination
of them all.
What worked for me was the following:
1. Put a Break Point in MFC source file DLGDATA.CPP on line 338 which
is:
TRACE0("Warning: skipping non-radio button in group.\n"); (Copyright
|
by: Wouter van Ooijen |
last post by:
I have a tool in Python to which I want to add a small GUI. The tools
currently runs everywhere PySerial is supported. I need a file-access
dialog. What is the preffered way to to this? Is there a
platform-independent file-access dialog available, or should I use the
windows native version when running on windows (and how do I do that)?
Wouter van Ooijen
-- ------------------------------------
|
by: Michael Yanowitz |
last post by:
Hello:
Below I have included a stripped down version of the GUI I am working on.
It contains 2 dialog boxes - one main and one settings. It has the following
problems, probably all related, that I am hoping someone knows what I am
doing wrong:
1) Pressing the Settings.. Button multiple times, brings up many instances
of the Settings Panel. I just want it to bring up one. Is there an easy
way to do that?
| |
by: Wouter |
last post by:
Hi,
I try to make the follow. I want that i can click on a text link and that
then a link wil be copyed in a input form box (<input type="text"
name="img_url" />).
I have google-ed about how i can make this but i cant find a explane how i
can do this. I'm sure my javascript skills are the problem....
Is there here someone who can help me whit this ?
|
by: vajratkarviraj |
last post by:
Hi all,
I'm using Python 2.5.1 and TkInter.
Hey here is the problem. Suppose I have 4 radio buttons (lets say values 1,2,3 and 4). They arranged in 2 columns (Each of the 2 columns has 2 radio buttons). I want to produce a specific action whenever I select a total of 2 radio buttons (and click on the "Submit" button), 1 from each column. Suppose say 1 and 3 are selected it should print 'a'. If 1 and 4, then print 'b' and similarly for radio...
|
by: nicstel |
last post by:
When we run this piece of code, we are getting a following error.
output error
File "src/lib/parametric/gen_freeze/Tkinter.py", line 1558, in init
AttributeError: 'module' object has no attribute 'argv'
piece of code
from Tkinter import *
|
by: nicstel |
last post by:
Hello.
My script run fine within python but not in my program(SDS/2 wich is a software like Autocad). The problem is I got an error when the time comes to read the line14 to 19. (Source code come from Tkinter.py)
class Tk(Misc, Wm):
"""Toplevel widget of Tk which represents mostly the main window
of an appliation. It has an associated Tcl interpreter."""
_w = '.'
def __init__(self, screenName=None, baseName=None,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |