473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Python GUI/tk

Hi,

I am making a GUI with the help of python.In the program, when "ADD"
button is pressed new frames build up and when you press "delete"
button those frames will be destroyed . My problem is that these frames
only get destroyed in Tk but the data structure associated with it (in
Python) doesn't change.
#!/usr/bin/python
from Tkinter import*

class Frame_1(LabelFrame):
def __init__(self,master):
LabelFrame.__init__(self,master)
self.configure(text="Frame1")
self.grid()

def control_buttons(self,frame):
Button( self, text = "Add", command = frame.add_button ).grid(
)
Button( self, text = "Read", command = frame.read_button
).grid()

class Frame_2(LabelFrame):
def __init__(self,master):
LabelFrame.__init__(self,master)
self.configure(text ="Frame2")
self.grid()
self.sub_frame = []

def add_button(self):
new_frame = Frame_2_1(self)
# new_frame.grid()
new_frame.populate()
self.sub_frame.append(new_frame)
# print self.sub_frame

def read_button(self):
print "#"*10
for sub_frame in self.sub_frame :
print "-"*30
print "band:"+ sub_frame.band.get()
print "channel:" + sub_frame.channel.get()

class Frame_2_1(LabelFrame):
def __init__(self,tkmaster):
LabelFrame.__init__(self,tkmaster)
self.configure(text ="DEFAULT")
self.grid()

def populate(self):
self.band = StringVar()
self.band.set("900")
option = OptionMenu(self, self.band,"900","1800","1900"
).grid()

self.channel = StringVar()
self.channel.set("CS 1")
option = OptionMenu(self,self.channel,"CS 1","CS 2","CS 3","CS
4").grid( )

global temp
temp= temp+1
Button(self,text = "Remove"+ str(temp),command=
self.delete_frame).grid()
def delete_frame(self):
self.destroy()

root = Tk()
temp=-1
# Create frame 1
frame_1 = Frame_1(root)
# Create frame 2
frame_2 = Frame_2(root)

frame_1.control_buttons(frame_2)
root.mainloop()
--------------------------------------------------------------------------

Sep 3 '06 #1
0 1109

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

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
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...
0
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...
0
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
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
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
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...
0
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...

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.