Tkinter GUI Question-Infinite Loop

Discussion in 'Python' started by prquinn@gmail.com, Mar 8, 2013.

  1. Guest

    Greetings,

    I'm trying to run a simple Tkinter program that opens a program when you click a button. The code is listed below. I use a command to call a programthat then calls a fortran program. However, when I click on the button, it opens the program but the menu of the program i'm calling goes into an infinite loop......the offending code seems to be in the button1Click module.

    Any help is greatly appreciated.

    Thanks

    from Tkinter import *
    import os, sys
    from win32com.client import Dispatch
    xlApp=Dispatch('Excel.Application')
    _PSSBINPATH=r"C:\Program Files\PTI\PSSE32\PSSBIN"
    os.environ['PATH']=_PSSBINPATH+';'+os.environ['PATH']
    sys.path.insert(0,_PSSBINPATH)
    import redirect; redirect.psse2py()
    import psspy

    class MyApp:
    def __init__(self, parent):
    self.myParent = parent ### (7) remember my parent, the root
    self.myContainer1 = Frame(parent)
    self.myContainer1.pack()

    self.button1 = Button(self.myContainer1)
    self.button1.configure(text="OK", background= "green")
    self.button1.pack(side=LEFT)
    self.button1.bind("<Button-1>", self.button1Click) ### (1)

    self.button2 = Button(self.myContainer1)
    self.button2.configure(text="Cancel", background="red")
    self.button2.pack(side=RIGHT)
    self.button2.bind("<Button-1>", self.button2Click) ### (2)

    def button1Click(self,event): ### (3)
    psspy.runiplanfile(r"C:\MNTACT\Contingency Program\work\contingency-31-4.irf")
    if self.button1["background"] == "green": ### (4)
    self.button1["background"] = "yellow"
    else:
    self.button1["background"] = "green"

    def button2Click(self, event): ### (5)
    self.myParent.destroy() ### (6)


    root = Tk()
    myapp = MyApp(root)
    root.mainloop()
     
    , Mar 8, 2013
    #1
    1. Advertising

  2. MRAB Guest

    On 08/03/2013 14:04, wrote:
    > Greetings,
    >
    > I'm trying to run a simple Tkinter program that opens a program when
    > you click a button. The code is listed below. I use a command to
    > call a program that then calls a fortran program. However, when I
    > click on the button, it opens the program but the menu of the program
    > i'm calling goes into an infinite loop......the offending code seems
    > to be in the button1Click module.
    >
    > Any help is greatly appreciated.
    >

    You say "the menu *of the program i'm calling* goes into an infinite
    loop" (my emphasis), so perhaps the problem isn't in _your_ code.

    Try something simpler like this:

    import psspy

    psspy.runiplanfile(r"C:\MNTACT\Contingency
    Program\work\contingency-31-4.irf")

    Does the program you're calling still go into an infinite loop?
     
    MRAB, Mar 8, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vedran Vukotic

    infinite loop unexpectly dies

    Vedran Vukotic, Mar 2, 2006, in forum: Perl
    Replies:
    0
    Views:
    4,479
    Vedran Vukotic
    Mar 2, 2006
  2. Alexander Bosch

    Infinite loop when using Server.Transfer

    Alexander Bosch, Oct 28, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    896
    Steven Cheng[MSFT]
    Nov 10, 2004
  3. Alexander Bosch

    Infinite loop when using Server.Transfer

    Alexander Bosch, Oct 31, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    555
    Steven Cheng[MSFT]
    Nov 1, 2004
  4. Replies:
    5
    Views:
    612
    benben
    Jan 31, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    397
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page