PDA

View Full Version : canīt close wx python window


jbrender
01-22-2009, 09:18 AM
Hallo,
i built my UI with wx python in maya works perfekt.
The Problem is that i can`t colse the Window any more I have to close Maya


import wx, Pmw, re, os, time,copy,sys,random ,shutil,thread

class wxHelloFrame(wx.Frame):

"""here are the controls for my window"""



class wxHelloApp(wx.App):

""" """

def OnInit(self):

""" """

frame = wxHelloFrame(None, title="wxHello")

frame.Show()



return True

if __name__ == "__main__":

app = wxHelloApp()

args = tuple()

ui = thread.start_new_thread(app.MainLoop,args)


anny suggestion

thanks

Jan

hblan
01-23-2009, 08:27 AM
import sys,wx,threading
import maya.cmds as mc


class frame(wx.Frame):
def __init__(self,myTitle):
wx.Frame.__init__(self,None,-1,title=myTitle)
button_1 = wx.Button(self,-1,"press me to make button")
button_1.Bind(wx.EVT_BUTTON,self.fn_makeSphere)

def fn_makeSphere(self,evt):
mc.sphere()


class theApp(wx.App):
def OnInit(self):
myFrame = frame("this title")
myFrame.Show()
return True

class theThread(threading.Thread):
def run(self):
lanApp = theApp(False)
lanApp.MainLoop()


lanThread = theThread()
lanThread.start()


running in maya 2008 . it works . but still have some bugs .
looks like wxpython thread have some effect to maya`s refresh system , i mean : after use it , a sphere created ,but when back to maya, u have to refresh the maya active scene manually , until u close the wxpython dialog . i have checked python threading doc , nothing helpful found .
wish somebody help me too . .

infect my code is edited outside of maya . so the last codes about lanThreading is like this :
if __name__ == "__main__":
lanThread = theThread()
lanThread.start()

and in maya , i made a python script tool in shelf . code to make a new one .like what i show u .

# u should add the path first .
import lan.py
reload(lan)
newThread = theThread()
newThread.start()


thanks .

CGTalk Moderation
01-23-2009, 08:27 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.