git-svn-id: http://moon:8086/svn/projects/HendiControl@253 fda53097-d464-4ada-af97-ba876c37ca34
48 lines
978 B
Python
48 lines
978 B
Python
#!/usr/bin/python3
|
|
#from core import MouseEvent
|
|
|
|
import wx
|
|
import colorsys as cs
|
|
|
|
class myGui(wx.Frame):
|
|
def __init__(self, *args, **kwargs):
|
|
super(myGui, self).__init__(*args, **kwargs)
|
|
|
|
self.InitUI()
|
|
|
|
def InitUI(self):
|
|
|
|
menubar = wx.MenuBar()
|
|
fileMenu = wx.Menu()
|
|
fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
|
|
menubar.Append(fileMenu, '&File')
|
|
self.SetMenuBar(menubar)
|
|
|
|
self.Bind(wx.EVT_MENU, self.OnQuit, fileItem)
|
|
self.Bind(wx.EVT_MOUSE_EVENTS, self.onMouse)
|
|
|
|
self.SetSize((300, 200))
|
|
self.SetTitle('Simple menu')
|
|
self.Centre()
|
|
|
|
def OnQuit(self, e):
|
|
self.Close()
|
|
|
|
def onMouse(self, e):
|
|
wxm = wx.MouseEvent(e)
|
|
rgb_f = cs.hsv_to_rgb(float(wxm.Position[0])/300, 1.0, float(wxm.Position[1])/200)
|
|
color = wx.Colour(int(rgb_f[0]*255), int(rgb_f[1]*255), int(rgb_f[2]*255))
|
|
self.SetBackgroundColour(color)
|
|
|
|
def main():
|
|
|
|
app = wx.App()
|
|
ex = myGui(None)
|
|
ex.Show()
|
|
app.MainLoop()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|