By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,408 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

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

100+
P: 440
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
Share this Question
Share on Google+
3 Replies


bartonc
Expert 5K+
P: 6,596
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

100+
P: 440
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

100+
P: 440
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.