Code: Alles auswählen
# -*- coding: cp1252 -*-
import os
import wx
class HPGL(wx.Frame):
def __init__(
self, parent = None, ID = 1, title = "CNC_Test V1.0", pos=wx.DefaultPosition,
size=(400,400), style= wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
):
wx.Frame.__init__(self, parent, ID, title, pos, size, style)
#Anzeigefeld
self.panel = wx.Panel(self, -1)
self.panel.SetBackgroundColour("sky blue")
#Button
self.button = wx.Button(self.panel, 1003, "Beenden",(163, 340), wx.DefaultSize)
self.bu_start = wx.Button(self.panel, -1, "Start",(60, 300), wx.DefaultSize)
self.bu_hpgl = wx.Button(self.panel, -1, "HPGL",(250, 300), wx.DefaultSize)
self.bu_MotXon = wx.Button(self.panel, -1, "MotXon",(15, 250), wx.DefaultSize)
self.bu_MotXoff = wx.Button(self.panel, -1, "MotXoff",(15, 225), wx.DefaultSize)
self.bu_MotYon = wx.Button(self.panel, -1, "MotYon",(100, 250), wx.DefaultSize)
self.bu_MotYoff = wx.Button(self.panel, -1, "MotYoff",(100, 225), wx.DefaultSize)
self.bu_MotZon = wx.Button(self.panel, -1, "MotZon",(185, 250), wx.DefaultSize)
self.bu_MotZoff = wx.Button(self.panel, -1, "MotZoff",(185, 225), wx.DefaultSize)
self.buttoncolor = (236, 236, 236, 100)
#Bindungen
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_BUTTON, self.Hpgl, self.bu_hpgl)
def OnCloseMe(self, event):
self.Close(True)
def OnCloseWindow(self, event):
self.Destroy()
def Hpgl(self,event):
dateipfad = None
wildcard = "TXT (*.txt)|*.txt|" \
"Drill (*.drd)|*.drd|" \
"HPGL (*.hpgl)|*.hpgl|" \
"All files (*.*)|*.*"
dlg = wx.FileDialog(
self, message="Eine Datei Wählen",
defaultDir=os.getcwd(),
defaultFile="",
wildcard=wildcard,
style=wx.OPEN | wx.CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
dateipfad = dlg.GetPath()
dlg.Destroy()
if dateipfad :
f = open(dateipfad)
pos = [map(int,l[l.find('PA')+2:-2].split(',')) for l in f.readlines() if 'PA' in l]
f.close()
print pos
def main():
app = wx.PySimpleApp()
fenster = HPGL()
fenster.Center()
fenster.Show()
app.MainLoop()
if __name__ == "__main__":
main()