Ich arbeite gerade an einer GUI in wxPython. Da ich allerdings Anfägner in Python bin habe ich noch einige Probleme.
Wie kann ich die erstellten TextCtrl durch Buttonklick zurücksetzen?
Wie kann ich den Ausgabetext des OpenFileDialoges (FilePath) in ein TextCtrl schreiben?
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import sys, os, wx
from wxPython.wx import *
class MainWindow(wx.Frame):
global bx, by, tx, ty
bx = 75
by = 24
tx = 100
ty = 20
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id, 'Pysmig', size=(300,190))
panel = wx.Panel(self,-1)
start = wx.Button(panel, label="Start", pos=(0,130), size=(bx,by))
#start.Bind(wx.EVT_BUTTON, self.start)
cancel = wx.Button(panel, label="Cancel/Reset", pos=(76,130), size=(bx,by))
cancel.Bind(wx.EVT_BUTTON, self.reset)
look = wx.Button(panel, label="Durchsuchen", pos=(195,20), size=(bx,by))
filet = look.Bind(wx.EVT_BUTTON, self.looking)
starttime = wx.TextCtrl(panel, pos=(85,80), size=(tx,ty))
endtime = wx.TextCtrl(panel, pos=(85,50), size=(tx,ty))
filet = wx.TextCtrl(panel, pos=(85,23),size=(tx,ty))
label = wx.StaticText(panel, label="Datei:", pos=(5,26))
label2 = wx.StaticText(panel, label="Startzeit [s]:", pos=(5,53))
label3 = wx.StaticText(panel, label="Endzeit, Dauer:", pos=(5,83))
self.box = wx.StaticBox(panel, -1, "Simulation", size=(290,120), pos=(0,0))
def looking(self,evt):
app = wx.PySimpleApp()
wildcard = "Python source (*.py)|*.py"
dialog = wx.FileDialog(None, "File auswählen", os.getcwd(),
"", wildcard, wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
print dialog.GetPath()
#return(dialog.GetPath())
dialog.Destroy()
def start(self):
execfile(filet)
def reset(self,evt):
panel.starttime.Clear()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MainWindow(parent=None, id=-1)
frame.Show()
app.MainLoop()