Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # generated by wxGlade 0.6.3
- import wx
- # begin wxGlade: extracode
- # end wxGlade
- class MyFrame(wx.Frame):
- def __init__(self, *args, **kwds):
- # begin wxGlade: MyFrame.__init__
- kwds["style"] = wx.CAPTION|wx.MINIMIZE|wx.CLOSE_BOX
- wx.Frame.__init__(self, *args, **kwds)
- self.label_1 = wx.StaticText(self, -1, "write anything!")
- self.toggle = wx.ToggleButton(self, -1, "toggle")
- self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
- self.__set_properties()
- self.__do_layout()
- self.Bind(wx.EVT_LEAVE_WINDOW, self.nofloat)
- self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
- self.text_ctrl_1.Bind(wx.EVT_TEXT, self.OnKD, self.text_ctrl_1)
- # end wxGlade
- def __set_properties(self):
- # begin wxGlade: MyFrame.__set_properties
- self.SetTitle("ifloat")
- self.SetSize((400, 200))
- self.toggle.SetPosition((0, 90))
- self.toggle.SetValue(1)
- self.toggle.Show(0)
- self.text_ctrl_1.SetPosition((0, 155))
- self.text_ctrl_1.SetSize((399, 40))
- self.text_ctrl_1.SetFocus()
- self.SetBackgroundColour(wx.Colour(0, 0, 0))
- self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
- self.timer = wx.Timer(self)
- self.count = 2
- # end wxGlade
- def __do_layout(self):
- # begin wxGlade: MyFrame.__do_layout
- sizer_1 = wx.BoxSizer(wx.VERTICAL)
- sizer_1.Add(self.label_1, 0, 0, 0)
- self.SetSizer(sizer_1)
- self.Layout()
- self.Centre()
- # end wxGlade
- def floatx(self, event):
- print self.timer.Start(50)
- event.Skip()
- def nofloat(self, event):
- self.timer.Stop()
- event.Skip()
- def OnTimer(self, event):
- self.count -= 1
- pos = self.label_1.GetPosition()
- val = self.toggle.GetValue()
- if self.count == 1:
- if val == 1:
- self.label_1.SetPosition(pos + (0, 2))
- if val == 0:
- self.label_1.SetPosition(pos - (0, 2))
- event.Skip()
- if self.count == 0:
- self.count = 2
- if pos == ((0, 140)):
- self.toggle.SetValue(0)
- if pos == ((0, 2)):
- if val == 0:
- self.label_1.SetPosition((0, 0))
- self.toggle.SetValue(1)
- event.Skip()
- event.Skip()
- def OnKD(self, event):
- print self.timer.Start(50)
- self.label_1.SetLabel('%s\n' % event.GetString())
- event.Skip()
- # end of class MyFrame
- if __name__ == "__main__":
- app = wx.PySimpleApp(0)
- wx.InitAllImageHandlers()
- frame_1 = MyFrame(None, -1, "")
- app.SetTopWindow(frame_1)
- frame_1.Show()
- app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement