473,714 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic Class + Dialogs doubt

Hi all,

I have a doubt with OOAD and Dialogs. I have a Dialog Class.
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

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

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


Main Program

from Tkinter import *
from tkSimpleDialog import Dialog
import tkMessageBox
import tkSimple
class SampleDialog(tk Simple.Dialog):
............... .......
............... ....
............... ...
def body(self, master):
self.title("Too l ")
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(r ow=7, sticky=W)
Label(master, text='').grid(r ow=8, sticky=W)
Label(master, text='Select a button below to add a
device').grid(r ow=9,
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.ge t()
Name2 = self.mitName.ge t()
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.Dialo g(self)

-------------..............e nd 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(titl e)

self.parent = parent

self.result = None

body = Frame(self)

self.initial_fo cus = self.body(body)
body.pack(padx= 5, pady=5)

self.buttonbox( )
self.protocol(" WM_DELETE_WINDO W", self.cancel)
self.geometry(" +%d+%d" % (parent.winfo_r ootx()+50,
parent.winfo_ro oty(
self.initial_fo cus.focus_set()

self.wait_windo w(self)
# construction hooks

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

def buttonbox(self) :
box = Frame(self)
w = Button(box, text="Save", width=10, command=self.ok ,
w.pack(side=LEF T, 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=LEF T, padx=5, pady=5)

#w = Button(box, text="Help", width=10, command=self.he lp)
#w.pack(side=LE FT, padx=5, pady=5)

w = Button(box, text="Cancel", width=10, command=self.ca ncel)
w.pack(side=LEF T, padx=5, pady=5)

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

def ok(self, event=None):

if not self.validate() :
self.initial_fo cus.focus_set()

self.update_idl etasks()
def cancel(self, event=None):
self.parent.foc us_set()

def validate(self):
return 1

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

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

Similar topics

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: file.py: --------------------- import file2 def hello(): print "Hello" file2.hello2()
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 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
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 ======================== import class_name as cn obj = cn.B() obj.printclass() ========================
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 process? 2. What information contained in sn key. I gone through that it is having public key. How it is using this key to intract with client. 3. When we have to run gacutil.exe file. Whenever we
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. The event in the singleton class always evaluates to null even when I cleary subscribe to it. Does anyone have some sample code of how to do this, or is this not possible.
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 types in objects. But if they are objects why it´s need this conversion? Aren´t objects (basic types) like Java?
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 transition my apps from VB6 to VB.NET, I'm curious about the best, most efficient way to include those in my application. Here's what I'm considering: 1. My gut reaction is to compile these routines into separate class libraries...
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 another ?
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 logical to have them all inherit from a base class that defines those, but this doesn't work: import tok class code: def __init__( self, start, stop ):
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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: 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: 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: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.