Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.85 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # generated by wxGlade 0.6.3
  4.  
  5. import wx
  6.  
  7. # begin wxGlade: extracode
  8. # end wxGlade
  9.  
  10.  
  11.  
  12. class MyFrame(wx.Frame):
  13.     def __init__(self, *args, **kwds):
  14.         # begin wxGlade: MyFrame.__init__
  15.         kwds["style"] = wx.CAPTION|wx.MINIMIZE|wx.CLOSE_BOX
  16.         wx.Frame.__init__(self, *args, **kwds)
  17.         self.label_1 = wx.StaticText(self, -1, "write anything!")
  18.         self.toggle = wx.ToggleButton(self, -1, "toggle")
  19.         self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
  20.  
  21.         self.__set_properties()
  22.         self.__do_layout()
  23.  
  24.         self.Bind(wx.EVT_LEAVE_WINDOW, self.nofloat)
  25.         self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
  26.         self.text_ctrl_1.Bind(wx.EVT_TEXT, self.OnKD, self.text_ctrl_1)
  27.         # end wxGlade
  28.  
  29.     def __set_properties(self):
  30.         # begin wxGlade: MyFrame.__set_properties
  31.         self.SetTitle("ifloat")
  32.         self.SetSize((400, 200))
  33.         self.toggle.SetPosition((0, 90))
  34.         self.toggle.SetValue(1)
  35.         self.toggle.Show(0)
  36.         self.text_ctrl_1.SetPosition((0, 155))
  37.         self.text_ctrl_1.SetSize((399, 40))
  38.         self.text_ctrl_1.SetFocus()
  39.         self.SetBackgroundColour(wx.Colour(0, 0, 0))
  40.         self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
  41.         self.timer = wx.Timer(self)
  42.         self.count = 2
  43.         # end wxGlade
  44.  
  45.     def __do_layout(self):
  46.         # begin wxGlade: MyFrame.__do_layout
  47.         sizer_1 = wx.BoxSizer(wx.VERTICAL)
  48.         sizer_1.Add(self.label_1, 0, 0, 0)
  49.         self.SetSizer(sizer_1)
  50.         self.Layout()
  51.         self.Centre()
  52.         # end wxGlade
  53.  
  54.     def floatx(self, event):
  55.         print self.timer.Start(50)
  56.         event.Skip()
  57.  
  58.     def nofloat(self, event):
  59.         self.timer.Stop()
  60.         event.Skip()
  61.  
  62.     def OnTimer(self, event):
  63.         self.count -= 1
  64.         pos = self.label_1.GetPosition()
  65.         val = self.toggle.GetValue()
  66.         if self.count == 1:
  67.             if val == 1:
  68.                 self.label_1.SetPosition(pos + (0, 2))
  69.             if val == 0:
  70.                 self.label_1.SetPosition(pos - (0, 2))
  71.             event.Skip()
  72.         if self.count == 0:
  73.             self.count = 2
  74.         if pos == ((0, 140)):
  75.             self.toggle.SetValue(0)
  76.         if pos == ((0, 2)):
  77.             if val == 0:
  78.                 self.label_1.SetPosition((0, 0))
  79.                 self.toggle.SetValue(1)
  80.             event.Skip()
  81.         event.Skip()
  82.  
  83.     def OnKD(self, event):
  84.         print self.timer.Start(50)
  85.         self.label_1.SetLabel('%s\n' % event.GetString())
  86.         event.Skip()
  87.  
  88. # end of class MyFrame
  89.  
  90.  
  91. if __name__ == "__main__":
  92.     app = wx.PySimpleApp(0)
  93.     wx.InitAllImageHandlers()
  94.     frame_1 = MyFrame(None, -1, "")
  95.     app.SetTopWindow(frame_1)
  96.     frame_1.Show()
  97.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement