Hi ,
Currenty I am storing the Graphical User Interface options in a string memeber variable of a class as show below: - SampleCode
-
Tkinter Modules ( Graphical User Interface):
-
-------------------------------------------------------------
-
a) File.py
-
class File:
-
def __init__(self):
-
self.__strInputFileName = ''
-
self.__strOutputFileName = ''
-
self.__xVal = 0.0
-
self.__yVal = 0.0
-
self.__zVal = 0.0
-
-
def set_input_file_name(self,strInFileName):
-
self.__strInputFileName = strInFileName
-
-
def set_output_file_name(self,strOutFileName):
-
self.__strOutputFileName = strOutFileName
-
-
def set_x_value(self,dXVal):
-
self.__xVal = dXVal
-
-
def set_y_value(self,dYVal):
-
self.__yVal = dYVal
-
-
def set_z_value(self,dzVal):
-
self.__zVal = dZVal
-
-
def get_input_file_name(self):
-
return self.__strInputFileName
-
-
def get_output_file_name(self):
-
return self.__strOutputFileName
-
-
def get_x_value(self):
-
return self.__xVal
-
-
def get_y_value(self):
-
return self.__yVal
-
-
def get_z_value(self):
-
return self.__zVal
-
-
b) FileGUI.py
-
-
class FileGUI:
-
def __init__(self):
-
pass
-
-
def store_values(self):
-
objFile = File()
-
# var1,var2,var3..var5 are the widget variables
-
objFile.set_input_file_name(var1.get())
-
objFile.set_output_file_name(var2.get())
-
objFile.set_x_value(var3.get())
-
objFile.set_y_value(var4.get())
-
objFile.set_z_value(var5.get())
-
return objFile
-
-
def call_fucntion():
-
objTest = TestFunctionality()
-
objTest.do_functionality(store_values())
-
-
c) Main.py
-
class TestFunctionality:
-
def __init__(self):
-
pass
-
-
def do_functionality(self,objFile):
-
objFile = File()
-
-
print objFile.get_input_file_name()
-
print objFile.get_output_file_name(var2.get())
-
print objFile.get_x_value(var3.get())
-
print objFile.get_y_value(var4.get())
-
print objFile.get_z_value(var5.get())
-
or I can store in the dict - SampleCode-2
-
a) FileDict.py
-
-
class FileDict:
-
def __init__(self):
-
pass
-
-
def store_values(self):
-
ParaDict={}
-
ParaDict['InputFileName']=var1.get()
-
ParaDict['OututFileName']=var2.get()
-
ParaDict['XVal']=var3.get()
-
ParaDict['YVal']=var4.get()
-
ParaDict['ZVal']=var5.get()
-
return ParaDict
-
-
def call_fucntion():
-
objTest = TestFunctionality()
-
objTest.do_functionality(store_values())
-
-
b) TestFunctionality.py
-
class TestFunctionality:
-
def __init__(self):
-
pass
-
-
def do_functionality(self,objFile):
-
objFile = File()
-
-
print ParaDict['InputFileName']
-
print ParaDict['OututFileName']
-
print ParaDict['XVal']
-
print ParaDict['YVal']
-
print ParaDict['ZVal']
-
-
Could anybody suggest which is the best way of storing the wedget options and try to use in the functionality
Thanks
PSB
6 1912
Hi ,
Currenty I am storing the Graphical User Interface options in a string memeber variable of a class as show below:
- SampleCode
-
Tkinter Modules ( Graphical User Interface):
-
-------------------------------------------------------------
-
a) File.py
-
class File:
-
def __init__(self):
-
self.__strInputFileName = ''
-
self.__strOutputFileName = ''
-
self.__xVal = 0.0
-
self.__yVal = 0.0
-
self.__zVal = 0.0
-
-
def set_input_file_name(self,strInFileName):
-
self.__strInputFileName = strInFileName
-
-
def set_output_file_name(self,strOutFileName):
-
self.__strOutputFileName = strOutFileName
-
-
def set_x_value(self,dXVal):
-
self.__xVal = dXVal
-
-
def set_y_value(self,dYVal):
-
self.__yVal = dYVal
-
-
def set_z_value(self,dzVal):
-
self.__zVal = dZVal
-
-
def get_input_file_name(self):
-
return self.__strInputFileName
-
-
def get_output_file_name(self):
-
return self.__strOutputFileName
-
-
def get_x_value(self):
-
return self.__xVal
-
-
def get_y_value(self):
-
return self.__yVal
-
-
def get_z_value(self):
-
return self.__zVal
-
-
b) FileGUI.py
-
-
class FileGUI:
-
def __init__(self):
-
pass
-
-
def store_values(self):
-
objFile = File()
-
# var1,var2,var3..var5 are the widget variables
-
objFile.set_input_file_name(var1.get())
-
objFile.set_output_file_name(var2.get())
-
objFile.set_x_value(var3.get())
-
objFile.set_y_value(var4.get())
-
objFile.set_z_value(var5.get())
-
return objFile
-
-
def call_fucntion():
-
objTest = TestFunctionality()
-
objTest.do_functionality(store_values())
-
-
c) Main.py
-
class TestFunctionality:
-
def __init__(self):
-
pass
-
-
def do_functionality(self,objFile):
-
objFile = File()
-
-
print objFile.get_input_file_name()
-
print objFile.get_output_file_name(var2.get())
-
print objFile.get_x_value(var3.get())
-
print objFile.get_y_value(var4.get())
-
print objFile.get_z_value(var5.get())
-
or I can store in the dict - SampleCode-2
-
a) FileDict.py
-
-
class FileDict:
-
def __init__(self):
-
pass
-
-
def store_values(self):
-
ParaDict={}
-
ParaDict['InputFileName']=var1.get()
-
ParaDict['OututFileName']=var2.get()
-
ParaDict['XVal']=var3.get()
-
ParaDict['YVal']=var4.get()
-
ParaDict['ZVal']=var5.get()
-
return ParaDict
-
-
def call_fucntion():
-
objTest = TestFunctionality()
-
objTest.do_functionality(store_values())
-
-
b) TestFunctionality.py
-
class TestFunctionality:
-
def __init__(self):
-
pass
-
-
def do_functionality(self,objFile):
-
objFile = File()
-
-
print ParaDict['InputFileName']
-
print ParaDict['OututFileName']
-
print ParaDict['XVal']
-
print ParaDict['YVal']
-
print ParaDict['ZVal']
-
-
Could anybody suggest which is the best way of storing the wedget options and try to use in the functionality
Thanks
PSB
BV/Barton,
Any comments on this.
Thanks
-PSB
BV/Barton,
Any comments on this.
Thanks
bartonc 6,596
Recognized Expert Expert
BV/Barton,
Any comments on this.
Thanks
Yes. I like the dictionary for organizing your variables. I use it quite often (almost as you have done here).
Yes. I like the dictionary for organizing your variables. I use it quite often (almost as you have done here).
Thanks Barton,
How about the first method of writing the code for storing the data?
-PSB
bartonc 6,596
Recognized Expert Expert
Thanks Barton,
How about the first method of writing the code for storing the data?
-PSB
Here's my favorite way to use a class (much like a C structure): -
>>> class FileDetails:
-
... def __init__(self, fname, **more_details):
-
... self.fname = fname
-
... for key, value in more_details.items():
-
... self.__dict__[key] = value
-
...
-
>>> myFileDetails = FileDetails("somefile", filesize = 1024)
-
>>> myFileDetails.fname
-
'somefile'
-
>>> myFileDetails.filesize
-
1024
-
>>>
bartonc 6,596
Recognized Expert Expert
Here's my favorite way to use a class (much like a C structure): -
>>> class FileDetails:
-
... def __init__(self, fname, **more_details):
-
... self.fname = fname
-
... for key, value in more_details.items():
-
... self.__dict__[key] = value
-
...
-
>>> myFileDetails = FileDetails("somefile", filesize = 1024)
-
>>> myFileDetails.fname
-
'somefile'
-
>>> myFileDetails.filesize
-
1024
-
>>>
It works with functions just as well: -
>>> def getValue():
-
... return 12
-
...
-
>>> myFileDetails = FileDetails("somefile", filesize = 1024, value_getter=getValue)
-
>>> myFileDetails.value_getter()
-
12
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Paul Rubin |
last post by:
I've been approached about writing a Windows app which will need a
really professional looking GUI. Forget TKinter, this has to actually
look good (real artists will be available to get the visual stuff
right). Assuming I write in Python, what's the best toolkit to use?
Some cost in implementation pain is tolerable if the finished
interface looks better as a result. It would be nice if the toolkit
runs on multiple platforms rather than...
|
by: Pekka Niiranen |
last post by:
Hi there,
after reading TkInter/thread -recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
I wondered if it was possible to avoid using threads
for the following problem:
I have script started from W2K console that normally
prints ascii messages to the screen. However, I have
command line "debug" -flag that might cause printing
|
by: Svenn Bjerkem |
last post by:
Hi,
Armed with Programming Python 3rd Edition and Learning Python 2nd
edition I try to write an application which I at first thought was
simple, at least until I was finished with the GUI and then wanted to
start putting some data into it.
As you will see, the program is not yet finished but I post what I have
so far.
|
by: psbasha |
last post by:
Hi,
I would like to call the same aplication executable with and without Graphical User Interface.
Requirement:
With Tkinter User interface,user can give the inputs to run the application ( Interactive).
Instead user will have this inputs in the file and it will be read by the batch utility or exe for the application
For example:
|
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: 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: 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: 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |