469,963 Members | 2,227 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

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

440 256MB
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 1815
bartonc
6,596 Expert 4TB
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 256MB
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.Suppose 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 256MB
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

Post your reply

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

Similar topics

reply views Thread by Mark 'Kamikaze' Hughes | last post: by
3 posts views Thread by srijit | last post: by
7 posts views Thread by SeeBelow | last post: by
7 posts views Thread by Justin Ezequiel | last post: by
2 posts views Thread by codecraig | last post: by
reply views Thread by syed_saqib_ali | last post: by
7 posts views Thread by Dick Moores | last post: by
44 posts views Thread by bg_ie | last post: by
8 posts views Thread by karthikbalaguru | last post: by
3 posts views Thread by joshdw4 | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.