473,544 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter- Creating the application call with and without Graphical User Inetrface

440 Contributor
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:

When we run the 'Sample.Exe' at the Python command prompt.It should ask for whether you want to run as Interactive-Yes, Batch (No).

Case-1 :- With User Interface:
------------------------------------------------

If user type 'Yes ',then Grapical User Interface has to display

Case-2 :- Without User Interface:
------------------------------------------------

if the user types 'No' ,then it should ask for the text file to be given as input tp execute the application.

To sumup:

if 'Yes':
# call Graphical User Interface
elif 'No'
# call batch application with < Sample1.in>

Can anybody guide me how to proceed with this options.

Thanks
PSB
May 18 '07 #1
3 2143
bartonc
6,596 Recognized Expert Expert
Here is something that might work for you.
Also included is the tkFileDialog with the native look and feel.
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import Tk, Label
  2. from tkFileDialog import askopenfilename
  3. from SimpleDialog import SimpleDialog
  4.  
  5.  
  6. if __name__ == '__main__':
  7.     root=Tk()
  8.     l = Label(root, text="Starting Application")
  9.     l.pack()
  10.     UIChooser = SimpleDialog(root, "Default is Batch Mode", ["Batch Mode", "Full GUI"],
  11.                              0, 0, "Choose the user interface")
  12.     choice = UIChooser.go()
  13.     if not choice:
  14.         fileName = askopenfilename()
  15.         print fileName
  16.         fileName = fileName or ""
  17.         root.destroy()
  18.     else:
  19.         l.config(text="Running Full GUI")
  20.         root.mainloop()
  21.  
May 19 '07 #2
psbasha
440 Contributor
Here is something that might work for you.
Also included is the tkFileDialog with the native look and feel.
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import Tk, Label
  2. from tkFileDialog import askopenfilename
  3. from SimpleDialog import SimpleDialog
  4.  
  5.  
  6. if __name__ == '__main__':
  7.     root=Tk()
  8.     l = Label(root, text="Starting Application")
  9.     l.pack()
  10.     UIChooser = SimpleDialog(root, "Default is Batch Mode", ["Batch Mode", "Full GUI"],
  11.                              0, 0, "Choose the user interface")
  12.     choice = UIChooser.go()
  13.     if not choice:
  14.         fileName = askopenfilename()
  15.         print fileName
  16.         fileName = fileName or ""
  17.         root.destroy()
  18.     else:
  19.         l.config(text="Running Full GUI")
  20.         root.mainloop()
  21.  
Thanks.

But I have to invoke the Batch and Interactive application.Sup pose if I am not having the Tkinter installed in my system,then Batch application has to work,if Tkinter is available then I can use either Batch( Without User Interface) or Interactive ( With User Interface)
-PSB
May 19 '07 #3
psbasha
440 Contributor
Here is something that might work for you.
Also included is the tkFileDialog with the native look and feel.
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import Tk, Label
  2. from tkFileDialog import askopenfilename
  3. from SimpleDialog import SimpleDialog
  4.  
  5.  
  6. if __name__ == '__main__':
  7.     root=Tk()
  8.     l = Label(root, text="Starting Application")
  9.     l.pack()
  10.     UIChooser = SimpleDialog(root, "Default is Batch Mode", ["Batch Mode", "Full GUI"],
  11.                              0, 0, "Choose the user interface")
  12.     choice = UIChooser.go()
  13.     if not choice:
  14.         fileName = askopenfilename()
  15.         print fileName
  16.         fileName = fileName or ""
  17.         root.destroy()
  18.     else:
  19.         l.config(text="Running Full GUI")
  20.         root.mainloop()
  21.  
Is this piece of code works in UNIX environment?
May 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4853
by: Mark 'Kamikaze' Hughes | last post by:
In the new Python game I'm developing, I need to crop out individual tiles from larger tilesets, and maintain transparency. Unfortunately, I've run into major deficiencies in both Tkinter and PIL (PyGame, wxPython, PyQt, etc. are not really suitable for this program, for a number of reasons, and I have zero interest in discussing why right...
3
6999
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter import * class App:
7
11885
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of wxPython. Mitchell Timin -- "Many are stubborn in pursuit of the path they have chosen, few in
7
4345
by: Justin Ezequiel | last post by:
What font is Tkinter using for displaying utf-8 characters? On my Windows XP, most of the characters with names (unicodedata.name) are displayed WYSIWYG. However, on my Mandrake (warning: Linux newbie), most characters are displayed as \u???? where ???? is the Hex code. ## start of script Tkinter_gui.py---------- import Tkinter import...
2
7372
by: codecraig | last post by:
Hi, I was reading through the Tkinter tutorial at http://www.pythonware.com/library/tkinter/introduction/index.htm ...and it mentions that by doing, from Tkinter import * you have access to the constants in Tkconstants, since Tkinter imports it automatically.
0
3568
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust accordingly. However, what I really want to happen is that the area of the canvas that the scrollbars show (the Scrollregion) should expand as the...
7
1651
by: Dick Moores | last post by:
In a couple of places recently I've seen Brent Welch's _Practical Programming in Tcl & Tk_ (<http://tinyurl.com/ynlk8b>) recommended for learning Tkinter well. So a couple of questions: 1) Is it really good for learning Tkinter, even though it doesn't mention Tkinter at all (in the 4th edition at least)? 2) If it is good for learning...
44
4964
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file processed by this script, where the concerned tmp file is only actually written to when PythonWin is closed. In other words, after I run this script, one of...
8
3267
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to my pc. But, it is not getting installed and is failing by throwing the below errors. Should i need to configure / install any specific files for...
3
2963
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm assuming this is because of the methods I'm using. I guess my question is two-fold. 1) How do I get rid of that window? 2) Any comments in general? I am just learning python (and coding with classes), so...
0
7439
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, 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...
0
7376
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...
0
7633
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, 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. ...
0
7785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7395
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...
0
7722
tracyyun
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...
1
5310
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1851
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
0
679
bsmnconsultancy
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...

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.