473,385 Members | 1,548 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,385 software developers and data experts.

Basic Class + Dialogs doubt

Hi all,

I have a doubt with OOAD and Dialogs. I have a Dialog Class.
tkSimple.py
It contains a class body as below. Now I am calling the tkSimple.py in
another python program and using the default body, and everything from
tkSimple.py.

Now my requirement is as follows I need to popup a couple of other
dialog boxes with a little difference in between each dialog and take
different values.

Summarising as below

Main window ----> tkSimple.py
Main window--ButtonClick ---> New dialog 1
Main window--Button 2 Click---> Another New Dialog 2.

Now I am wondering how I can put three different types of dialogs in
the same tksimple.py and call them at different conditions in my main
class

I am including the code here. Right now I have created multiple copies
of the tkSimple.py like tkSimple1.py tkSimple2.py and importing them
whereever I need them

regards,
Mahesh

Main Program
---------------

from Tkinter import *
from tkSimpleDialog import Dialog
import tkMessageBox
import tkSimple
class SampleDialog(tkSimple.Dialog):
......................
...................
..................
def body(self, master):
self.title("Tool ")
self.geometry("400x500")
# All the constant values goes here.
# Labels
Label(master, text='BSS ATTRIB TOOL').grid(row=1, sticky=W)
Label(master, text=' ').grid(row=2, sticky=W)
Label(master, text=' ').grid(row=3, sticky=W)
Label(master, text=' ').grid(row=4, sticky=W)
Label(master, text='BSS Name').grid(row=5, sticky=W)
Label(master, text='MIT VErsion').grid(row=6, sticky=W)
#Choosing the device type belonging to which class goes here.
v = IntVar()
global CnType
CnType = IntVar()
Label(master, text='').grid(row=7, sticky=W)
Label(master, text='').grid(row=8, sticky=W)
Label(master, text='Select a button below to add a
device').grid(row=9,
sticky=W)
optTp = Button(master, text ="Click here to add a Class A
device", comma
nd=self.ShowA).grid(row=10, column=0, sticky=W)
@

def apply(self):
Name1 = self.bssName.get()
Name2 = self.mitName.get()
global CnType
global deviceClass
deviceClass = CnType.get()
print deviceClass

#Boby's Code to place the above values in the file pass
def ShowA(self):
global DialogType
DialogType = 2

getValue = tkSimple1.Dialog(self)

-------------..............end of main program

TkSimple.py Code
-----------------------------

from Tkinter import *
import os

class Dialog(Toplevel):

def __init__(self, parent, title = None):

Toplevel.__init__(self, parent)
self.transient(parent)

if title:
self.title(title)

self.parent = parent

self.result = None

body = Frame(self)

self.initial_focus = self.body(body)
body.pack(padx=5, pady=5)

self.buttonbox()
self.protocol("WM_DELETE_WINDOW", self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
parent.winfo_rooty(
)+50))
self.initial_focus.focus_set()

self.wait_window(self)
# construction hooks

def body(self, master):
# create dialog body. return widget that should have intial
focus.
pass

def buttonbox(self):
box = Frame(self)
w = Button(box, text="Save", width=10, command=self.ok,
default=ACTIVE)
w.pack(side=LEFT, padx=5, pady=5)

#Need to change the command here .<Mahesh>

w = Button(box, text="Run Tool", width=10, command=self.ok)
w = Button(box, text="Run Tool", width=10, command=self.ok)
w.pack(side=LEFT, padx=5, pady=5)

#w = Button(box, text="Help", width=10, command=self.help)
#w.pack(side=LEFT, padx=5, pady=5)

w = Button(box, text="Cancel", width=10, command=self.cancel)
w.pack(side=LEFT, padx=5, pady=5)

self.bind("&lt;Return.", self.ok)
self.bind("&lt:Escape.", self.cancel)

box.pack()
def ok(self, event=None):

if not self.validate():
self.initial_focus.focus_set()
return

self.withdraw()
self.update_idletasks()
self.apply()
self.cancel()
def cancel(self, event=None):
self.parent.focus_set()
self.destroy()

def validate(self):
return 1

def apply(self):
pass
Jul 18 '05 #1
0 1371

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

Similar topics

9
by: Frantisek Fuka | last post by:
This thing keeps bugging me. It's probably some basic misunderstanding on my part but I am stumped. Let's say I have two Python files: file.py and file2.py. Their contents is as follows: ...
0
by: mahesh | last post by:
Hi all, I have a doubt with OOAD and Dialogs. I have a Dialog Class. tkSimple.py It contains a class body as below. Now I am calling the tkSimple.py in another python program and using the...
0
by: flupke | last post by:
I have the following test code setup, trying to get the class name of a subclass in the super class. (Reason why i want this is described below) file class_name_start.py ========================...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
10
by: Opa | last post by:
I have tried for two days to solve this problem with no luck. I have a singleton class which has some events declared. When I inherit from this class the events don't seem to come along with it....
14
by: luis | last post by:
Are basic types (int, long, ...) objetcs or not? I read that in C# all are objects including basic types, derived from Object class. Then in msdn documentation says that boxing converts basic...
5
by: Graham Charles | last post by:
I've got several generic "library" routines that are used by many of my controls & applications (things like string manipulation, generic error handling, an "about" box generator, etc.). As I...
25
by: toffee | last post by:
Hi all, apologies if this seems like a pretty basic question - but can an element have more than one class? if so, how do you set them ? and how does the browser give priority to a class over...
14
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.