Add files via upload
This commit is contained in:
parent
a1b949ff7d
commit
7efd341276
9 changed files with 274 additions and 44 deletions
|
@ -3,7 +3,6 @@ from pygwin.tray import tray as _tray
|
||||||
from datetime import datetime as _dt
|
from datetime import datetime as _dt
|
||||||
from pygwin.image import save as _s
|
from pygwin.image import save as _s
|
||||||
from pygwin._pg import pg as _pg
|
from pygwin._pg import pg as _pg
|
||||||
import pygwin._icon as _icon
|
|
||||||
import pygwin.image as _img
|
import pygwin.image as _img
|
||||||
import win32job as _w32j
|
import win32job as _w32j
|
||||||
import win32api as _w32a
|
import win32api as _w32a
|
||||||
|
@ -30,7 +29,7 @@ class win(_surface):
|
||||||
_pg.display.update()
|
_pg.display.update()
|
||||||
def title():
|
def title():
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return _pg.display.get_caption()
|
return _pg.display.get_caption()[0]
|
||||||
def fset(self, value):
|
def fset(self, value):
|
||||||
if type(value) != str:
|
if type(value) != str:
|
||||||
return
|
return
|
||||||
|
@ -110,14 +109,6 @@ def create(title=None, size=(0,0), icon=None, resizable=False, noframe=False):
|
||||||
if icon != None:
|
if icon != None:
|
||||||
_pg.display.set_icon(_pg.image.load(icon))
|
_pg.display.set_icon(_pg.image.load(icon))
|
||||||
return win(icon)
|
return win(icon)
|
||||||
else:
|
|
||||||
surf = _img.fromBytes(_icon.iconbytes)
|
|
||||||
try:
|
|
||||||
orig = surf._surface_orig
|
|
||||||
except:
|
|
||||||
orig = surf._orig
|
|
||||||
_pg.display.set_icon(orig)
|
|
||||||
return win()
|
|
||||||
|
|
||||||
def ramLimit(memory_limit):
|
def ramLimit(memory_limit):
|
||||||
hjob = _w32j.CreateJobObject(None, job_name)
|
hjob = _w32j.CreateJobObject(None, job_name)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import threading
|
||||||
import wx
|
import wx
|
||||||
import wx.adv
|
import wx.adv
|
||||||
from pygwin._pg import pg
|
from pygwin._pg import pg
|
||||||
|
import copy
|
||||||
|
|
||||||
class tray(wx.adv.TaskBarIcon):
|
class tray(wx.adv.TaskBarIcon):
|
||||||
def __init__(self, tooltip, iconpath):
|
def __init__(self, tooltip, iconpath):
|
||||||
|
@ -14,40 +15,35 @@ class tray(wx.adv.TaskBarIcon):
|
||||||
self.frame = self._app.frame
|
self.frame = self._app.frame
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._tooltip = tooltip
|
self._tooltip = tooltip
|
||||||
|
self._iconpath = iconpath
|
||||||
self.setIcon(iconpath)
|
self.setIcon(iconpath)
|
||||||
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN,
|
|
||||||
lambda x:self.onLeftMouseButton())
|
|
||||||
self._menu = wx.Menu()
|
self._menu = wx.Menu()
|
||||||
|
|
||||||
def CreatePopupMenu(self):
|
def CreatePopupMenu(self):
|
||||||
return self._menu
|
return self._menu
|
||||||
|
def GetPopupMenu(self):
|
||||||
|
return self._menu
|
||||||
def setIcon(self, path):
|
def setIcon(self, path):
|
||||||
self._bicon = wx.Icon(wx.Bitmap(path))
|
self._bicon = wx.Icon(wx.Bitmap(path))
|
||||||
self.SetIcon(self._bicon, self._tooltip)
|
self.SetIcon(self._bicon, self._tooltip)
|
||||||
|
|
||||||
def setTooltip(self, tooltip):
|
def setTooltip(self, tooltip):
|
||||||
self.SetIcon(self._bicon, tooltip)
|
self.SetIcon(self._bicon, tooltip)
|
||||||
self._tooltip = tooltip
|
self._tooltip = tooltip
|
||||||
|
|
||||||
def onLeftMouseButton(self):
|
def onLeftMouseButton(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addSeparator(self):
|
def addSeparator(self):
|
||||||
self._menu.AppendSeparator()
|
self._menu.AppendSeparator()
|
||||||
|
|
||||||
def addCommand(self,text,func=lambda:None):
|
def addCommand(self,text,func=lambda:None):
|
||||||
item = wx.MenuItem(self._menu,-1,text)
|
item = wx.MenuItem(self._menu,-1,text)
|
||||||
self._menu.Bind(wx.EVT_MENU,
|
self._menu.Bind(wx.EVT_MENU,
|
||||||
lambda x:func(),
|
lambda x:func(),
|
||||||
id=item.GetId())
|
id=item.GetId())
|
||||||
self._menu.Append(item)
|
self._menu.Append(item)
|
||||||
|
|
||||||
def start(self, thread=True):
|
def start(self, thread=True):
|
||||||
|
cbotld = lambda x:self.onLeftMouseButton()
|
||||||
|
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN,cbotld)
|
||||||
if thread: threading.Thread(
|
if thread: threading.Thread(
|
||||||
target=self._app.MainLoop,
|
target=self._app.MainLoop,
|
||||||
daemon=1).start()
|
daemon=1).start()
|
||||||
else: self._app.MainLoop()
|
else: self._app.MainLoop()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
wx.CallAfter(self._app.frame.Close)
|
wx.CallAfter(self._app.frame.Close)
|
||||||
|
|
|
@ -182,6 +182,135 @@ class entry(widget):
|
||||||
x = self.surface.size[0]-text.size[0]-10
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
|
||||||
|
if position != None:
|
||||||
|
if self.surface.rect(position[0],
|
||||||
|
position[1]).contains(_m.getPosition()[0],
|
||||||
|
_m.getPosition()[1]):
|
||||||
|
if not self.wcl:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_HAND)
|
||||||
|
else:
|
||||||
|
if not self.ws:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
|
||||||
|
self.ws = True
|
||||||
|
if _m.isPressed('left'):
|
||||||
|
if not self.wcl:
|
||||||
|
self.focus=self.focus==0
|
||||||
|
self.wcl = True
|
||||||
|
else:
|
||||||
|
self.wcl = False
|
||||||
|
self.wsnr = False
|
||||||
|
else:
|
||||||
|
if not self.wsnr:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
|
||||||
|
self.wsnr = True
|
||||||
|
if _m.isPressed('left'):
|
||||||
|
self.focus = False
|
||||||
|
def insert(self,text):
|
||||||
|
if _ct.WinDLL("User32.dll").GetKeyState(0x14):
|
||||||
|
text = text.upper()
|
||||||
|
if hex(getattr(_ct.windll.LoadLibrary("user32.dll"), "GetKeyboardLayout")(0))=='0x4190419':
|
||||||
|
text = text.translate(dict(zip(map(ord, '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'''),
|
||||||
|
'''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё''')))
|
||||||
|
if text in self.blacklist:
|
||||||
|
return
|
||||||
|
if self.whitelist != None:
|
||||||
|
if text not in self.whitelist:
|
||||||
|
return
|
||||||
|
if self.maxSymbols != None:
|
||||||
|
if len(text) > self.maxSymbols:
|
||||||
|
return
|
||||||
|
self.text += text
|
||||||
|
def delete(self,symbols=1):
|
||||||
|
self.text = self.text[:0-symbols]
|
||||||
|
def draw(self, win, pos):
|
||||||
|
self._generate(pos)
|
||||||
|
win.blit(self.surface,pos)
|
||||||
|
def get(self):
|
||||||
|
return text
|
||||||
|
class textarea(widget):
|
||||||
|
def __init__(self,hint='',fontSize=30,
|
||||||
|
font=_df,width=None,bg=(70,70,70),
|
||||||
|
fg=(180,180,200),afg=(200,200,200),
|
||||||
|
abg=(50,50,50),hintColor=(100,100,100),
|
||||||
|
lineColor=(200,200,200),
|
||||||
|
borderColor=(50,50,50),
|
||||||
|
borderWidth=5,maxSymbols=None,
|
||||||
|
whitelist=None,blacklist=[]):
|
||||||
|
super()._args(locals())
|
||||||
|
self.text = ''
|
||||||
|
self.focus = False
|
||||||
|
self.tick = 0
|
||||||
|
self.wcl = False
|
||||||
|
self.startHint = self.hint
|
||||||
|
self.ws = False
|
||||||
|
if self.width == None:
|
||||||
|
if self.hint != '':
|
||||||
|
hintSize = self.font.size(self.hint,self.fontSize)
|
||||||
|
else:
|
||||||
|
hintSize = (150,self.font.size('X',self.fontSize)[1])
|
||||||
|
self.height = hintSize[1]+10
|
||||||
|
if self.width == None:
|
||||||
|
self.width = hintSize[0]+50
|
||||||
|
self.surface = _s((self.width,self.height))
|
||||||
|
self.wclk = []
|
||||||
|
self.wsnr = False
|
||||||
|
def _generate(self,position=None):
|
||||||
|
self.surface.fill(self.borderColor)
|
||||||
|
if self.focus:
|
||||||
|
if self.text != '':
|
||||||
|
self.height = self.font.size(self.text,self.fontSize)[1]+10
|
||||||
|
self.surface = _s((self.width,self.height))
|
||||||
|
self.surface.fill(self.borderColor)
|
||||||
|
self.surface.draw.rect(self.abg,_r(self.borderWidth,self.borderWidth,
|
||||||
|
self.surface.size[0]-self.borderWidth*2,
|
||||||
|
self.surface.size[1]-self.borderWidth*2))
|
||||||
|
if self.text == '':
|
||||||
|
text = self.font.render(self.hint,self.fontSize,self.hintColor)
|
||||||
|
else:
|
||||||
|
text = self.font.render(self.text,self.fontSize,self.afg)
|
||||||
|
x = 10
|
||||||
|
if text.size[0] >= self.surface.size[0]-20:
|
||||||
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
for i in _k.getPressed().items():
|
||||||
|
if i[1]:
|
||||||
|
if i[0] not in self.wclk:
|
||||||
|
if len(i[0]) == 1:
|
||||||
|
self.insert(i[0])
|
||||||
|
elif i[0] == 'backspace':
|
||||||
|
self.delete()
|
||||||
|
elif i[0] == 'return':
|
||||||
|
if self.maxSymbols != None:
|
||||||
|
if len(text) > self.maxSymbols:
|
||||||
|
continue
|
||||||
|
self.text += '\n'
|
||||||
|
elif i[0] == 'space':
|
||||||
|
self.insert(' ')
|
||||||
|
self.wclk.append(i[0])
|
||||||
|
else:
|
||||||
|
if i[0] in self.wclk:
|
||||||
|
self.wclk.remove(i[0])
|
||||||
|
self.tick += 1
|
||||||
|
if self.tick >= 60:
|
||||||
|
if self.text != '':
|
||||||
|
points = [[x+text.size[0],self.surface.size[1]/2-text.size[1]/2],
|
||||||
|
[x+text.size[0],self.surface.size[1]/2-text.size[1]/2+self.surface.size[1]-10]]
|
||||||
|
self.surface.draw.line(self.lineColor,points[0],points[1],3)
|
||||||
|
if self.tick == 120:
|
||||||
|
self.tick = 0
|
||||||
|
else:
|
||||||
|
self.surface.draw.rect(self.bg,_r(self.borderWidth,self.borderWidth,
|
||||||
|
self.surface.size[0]-self.borderWidth*2,
|
||||||
|
self.surface.size[1]-self.borderWidth*2))
|
||||||
|
if self.text == '':
|
||||||
|
text = self.font.render(self.hint,self.fontSize,self.hintColor)
|
||||||
|
else:
|
||||||
|
text = self.font.render(self.text,self.fontSize,self.fg)
|
||||||
|
x = self.surface.size[0]/2-text.size[0]/2
|
||||||
|
if text.size[0] >= self.surface.size[0]-20:
|
||||||
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
|
||||||
if position != None:
|
if position != None:
|
||||||
if self.surface.rect(position[0],
|
if self.surface.rect(position[0],
|
||||||
position[1]).contains(_m.getPosition()[0],
|
position[1]).contains(_m.getPosition()[0],
|
||||||
|
|
BIN
dist/pygwin-0.1.0-py3.7.egg
vendored
BIN
dist/pygwin-0.1.0-py3.7.egg
vendored
Binary file not shown.
|
@ -1,6 +1,5 @@
|
||||||
setup.py
|
setup.py
|
||||||
pygwin/__init__.py
|
pygwin/__init__.py
|
||||||
pygwin/_icon.py
|
|
||||||
pygwin/_pg.py
|
pygwin/_pg.py
|
||||||
pygwin/_win.py
|
pygwin/_win.py
|
||||||
pygwin/console.py
|
pygwin/console.py
|
||||||
|
|
|
@ -3,7 +3,6 @@ from pygwin.tray import tray as _tray
|
||||||
from datetime import datetime as _dt
|
from datetime import datetime as _dt
|
||||||
from pygwin.image import save as _s
|
from pygwin.image import save as _s
|
||||||
from pygwin._pg import pg as _pg
|
from pygwin._pg import pg as _pg
|
||||||
import pygwin._icon as _icon
|
|
||||||
import pygwin.image as _img
|
import pygwin.image as _img
|
||||||
import win32job as _w32j
|
import win32job as _w32j
|
||||||
import win32api as _w32a
|
import win32api as _w32a
|
||||||
|
@ -30,7 +29,7 @@ class win(_surface):
|
||||||
_pg.display.update()
|
_pg.display.update()
|
||||||
def title():
|
def title():
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return _pg.display.get_caption()
|
return _pg.display.get_caption()[0]
|
||||||
def fset(self, value):
|
def fset(self, value):
|
||||||
if type(value) != str:
|
if type(value) != str:
|
||||||
return
|
return
|
||||||
|
@ -110,14 +109,6 @@ def create(title=None, size=(0,0), icon=None, resizable=False, noframe=False):
|
||||||
if icon != None:
|
if icon != None:
|
||||||
_pg.display.set_icon(_pg.image.load(icon))
|
_pg.display.set_icon(_pg.image.load(icon))
|
||||||
return win(icon)
|
return win(icon)
|
||||||
else:
|
|
||||||
surf = _img.fromBytes(_icon.iconbytes)
|
|
||||||
try:
|
|
||||||
orig = surf._surface_orig
|
|
||||||
except:
|
|
||||||
orig = surf._orig
|
|
||||||
_pg.display.set_icon(orig)
|
|
||||||
return win()
|
|
||||||
|
|
||||||
def ramLimit(memory_limit):
|
def ramLimit(memory_limit):
|
||||||
hjob = _w32j.CreateJobObject(None, job_name)
|
hjob = _w32j.CreateJobObject(None, job_name)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import threading
|
||||||
import wx
|
import wx
|
||||||
import wx.adv
|
import wx.adv
|
||||||
from pygwin._pg import pg
|
from pygwin._pg import pg
|
||||||
|
import copy
|
||||||
|
|
||||||
class tray(wx.adv.TaskBarIcon):
|
class tray(wx.adv.TaskBarIcon):
|
||||||
def __init__(self, tooltip, iconpath):
|
def __init__(self, tooltip, iconpath):
|
||||||
|
@ -14,40 +15,35 @@ class tray(wx.adv.TaskBarIcon):
|
||||||
self.frame = self._app.frame
|
self.frame = self._app.frame
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._tooltip = tooltip
|
self._tooltip = tooltip
|
||||||
|
self._iconpath = iconpath
|
||||||
self.setIcon(iconpath)
|
self.setIcon(iconpath)
|
||||||
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN,
|
|
||||||
lambda x:self.onLeftMouseButton())
|
|
||||||
self._menu = wx.Menu()
|
self._menu = wx.Menu()
|
||||||
|
|
||||||
def CreatePopupMenu(self):
|
def CreatePopupMenu(self):
|
||||||
return self._menu
|
return self._menu
|
||||||
|
def GetPopupMenu(self):
|
||||||
|
return self._menu
|
||||||
def setIcon(self, path):
|
def setIcon(self, path):
|
||||||
self._bicon = wx.Icon(wx.Bitmap(path))
|
self._bicon = wx.Icon(wx.Bitmap(path))
|
||||||
self.SetIcon(self._bicon, self._tooltip)
|
self.SetIcon(self._bicon, self._tooltip)
|
||||||
|
|
||||||
def setTooltip(self, tooltip):
|
def setTooltip(self, tooltip):
|
||||||
self.SetIcon(self._bicon, tooltip)
|
self.SetIcon(self._bicon, tooltip)
|
||||||
self._tooltip = tooltip
|
self._tooltip = tooltip
|
||||||
|
|
||||||
def onLeftMouseButton(self):
|
def onLeftMouseButton(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addSeparator(self):
|
def addSeparator(self):
|
||||||
self._menu.AppendSeparator()
|
self._menu.AppendSeparator()
|
||||||
|
|
||||||
def addCommand(self,text,func=lambda:None):
|
def addCommand(self,text,func=lambda:None):
|
||||||
item = wx.MenuItem(self._menu,-1,text)
|
item = wx.MenuItem(self._menu,-1,text)
|
||||||
self._menu.Bind(wx.EVT_MENU,
|
self._menu.Bind(wx.EVT_MENU,
|
||||||
lambda x:func(),
|
lambda x:func(),
|
||||||
id=item.GetId())
|
id=item.GetId())
|
||||||
self._menu.Append(item)
|
self._menu.Append(item)
|
||||||
|
|
||||||
def start(self, thread=True):
|
def start(self, thread=True):
|
||||||
|
cbotld = lambda x:self.onLeftMouseButton()
|
||||||
|
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN,cbotld)
|
||||||
if thread: threading.Thread(
|
if thread: threading.Thread(
|
||||||
target=self._app.MainLoop,
|
target=self._app.MainLoop,
|
||||||
daemon=1).start()
|
daemon=1).start()
|
||||||
else: self._app.MainLoop()
|
else: self._app.MainLoop()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
wx.CallAfter(self._app.frame.Close)
|
wx.CallAfter(self._app.frame.Close)
|
||||||
|
|
129
pygwin/ui.py
129
pygwin/ui.py
|
@ -182,6 +182,135 @@ class entry(widget):
|
||||||
x = self.surface.size[0]-text.size[0]-10
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
|
||||||
|
if position != None:
|
||||||
|
if self.surface.rect(position[0],
|
||||||
|
position[1]).contains(_m.getPosition()[0],
|
||||||
|
_m.getPosition()[1]):
|
||||||
|
if not self.wcl:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_HAND)
|
||||||
|
else:
|
||||||
|
if not self.ws:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
|
||||||
|
self.ws = True
|
||||||
|
if _m.isPressed('left'):
|
||||||
|
if not self.wcl:
|
||||||
|
self.focus=self.focus==0
|
||||||
|
self.wcl = True
|
||||||
|
else:
|
||||||
|
self.wcl = False
|
||||||
|
self.wsnr = False
|
||||||
|
else:
|
||||||
|
if not self.wsnr:
|
||||||
|
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
|
||||||
|
self.wsnr = True
|
||||||
|
if _m.isPressed('left'):
|
||||||
|
self.focus = False
|
||||||
|
def insert(self,text):
|
||||||
|
if _ct.WinDLL("User32.dll").GetKeyState(0x14):
|
||||||
|
text = text.upper()
|
||||||
|
if hex(getattr(_ct.windll.LoadLibrary("user32.dll"), "GetKeyboardLayout")(0))=='0x4190419':
|
||||||
|
text = text.translate(dict(zip(map(ord, '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'''),
|
||||||
|
'''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё''')))
|
||||||
|
if text in self.blacklist:
|
||||||
|
return
|
||||||
|
if self.whitelist != None:
|
||||||
|
if text not in self.whitelist:
|
||||||
|
return
|
||||||
|
if self.maxSymbols != None:
|
||||||
|
if len(text) > self.maxSymbols:
|
||||||
|
return
|
||||||
|
self.text += text
|
||||||
|
def delete(self,symbols=1):
|
||||||
|
self.text = self.text[:0-symbols]
|
||||||
|
def draw(self, win, pos):
|
||||||
|
self._generate(pos)
|
||||||
|
win.blit(self.surface,pos)
|
||||||
|
def get(self):
|
||||||
|
return text
|
||||||
|
class textarea(widget):
|
||||||
|
def __init__(self,hint='',fontSize=30,
|
||||||
|
font=_df,width=None,bg=(70,70,70),
|
||||||
|
fg=(180,180,200),afg=(200,200,200),
|
||||||
|
abg=(50,50,50),hintColor=(100,100,100),
|
||||||
|
lineColor=(200,200,200),
|
||||||
|
borderColor=(50,50,50),
|
||||||
|
borderWidth=5,maxSymbols=None,
|
||||||
|
whitelist=None,blacklist=[]):
|
||||||
|
super()._args(locals())
|
||||||
|
self.text = ''
|
||||||
|
self.focus = False
|
||||||
|
self.tick = 0
|
||||||
|
self.wcl = False
|
||||||
|
self.startHint = self.hint
|
||||||
|
self.ws = False
|
||||||
|
if self.width == None:
|
||||||
|
if self.hint != '':
|
||||||
|
hintSize = self.font.size(self.hint,self.fontSize)
|
||||||
|
else:
|
||||||
|
hintSize = (150,self.font.size('X',self.fontSize)[1])
|
||||||
|
self.height = hintSize[1]+10
|
||||||
|
if self.width == None:
|
||||||
|
self.width = hintSize[0]+50
|
||||||
|
self.surface = _s((self.width,self.height))
|
||||||
|
self.wclk = []
|
||||||
|
self.wsnr = False
|
||||||
|
def _generate(self,position=None):
|
||||||
|
self.surface.fill(self.borderColor)
|
||||||
|
if self.focus:
|
||||||
|
if self.text != '':
|
||||||
|
self.height = self.font.size(self.text,self.fontSize)[1]+10
|
||||||
|
self.surface = _s((self.width,self.height))
|
||||||
|
self.surface.fill(self.borderColor)
|
||||||
|
self.surface.draw.rect(self.abg,_r(self.borderWidth,self.borderWidth,
|
||||||
|
self.surface.size[0]-self.borderWidth*2,
|
||||||
|
self.surface.size[1]-self.borderWidth*2))
|
||||||
|
if self.text == '':
|
||||||
|
text = self.font.render(self.hint,self.fontSize,self.hintColor)
|
||||||
|
else:
|
||||||
|
text = self.font.render(self.text,self.fontSize,self.afg)
|
||||||
|
x = 10
|
||||||
|
if text.size[0] >= self.surface.size[0]-20:
|
||||||
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
for i in _k.getPressed().items():
|
||||||
|
if i[1]:
|
||||||
|
if i[0] not in self.wclk:
|
||||||
|
if len(i[0]) == 1:
|
||||||
|
self.insert(i[0])
|
||||||
|
elif i[0] == 'backspace':
|
||||||
|
self.delete()
|
||||||
|
elif i[0] == 'return':
|
||||||
|
if self.maxSymbols != None:
|
||||||
|
if len(text) > self.maxSymbols:
|
||||||
|
continue
|
||||||
|
self.text += '\n'
|
||||||
|
elif i[0] == 'space':
|
||||||
|
self.insert(' ')
|
||||||
|
self.wclk.append(i[0])
|
||||||
|
else:
|
||||||
|
if i[0] in self.wclk:
|
||||||
|
self.wclk.remove(i[0])
|
||||||
|
self.tick += 1
|
||||||
|
if self.tick >= 60:
|
||||||
|
if self.text != '':
|
||||||
|
points = [[x+text.size[0],self.surface.size[1]/2-text.size[1]/2],
|
||||||
|
[x+text.size[0],self.surface.size[1]/2-text.size[1]/2+self.surface.size[1]-10]]
|
||||||
|
self.surface.draw.line(self.lineColor,points[0],points[1],3)
|
||||||
|
if self.tick == 120:
|
||||||
|
self.tick = 0
|
||||||
|
else:
|
||||||
|
self.surface.draw.rect(self.bg,_r(self.borderWidth,self.borderWidth,
|
||||||
|
self.surface.size[0]-self.borderWidth*2,
|
||||||
|
self.surface.size[1]-self.borderWidth*2))
|
||||||
|
if self.text == '':
|
||||||
|
text = self.font.render(self.hint,self.fontSize,self.hintColor)
|
||||||
|
else:
|
||||||
|
text = self.font.render(self.text,self.fontSize,self.fg)
|
||||||
|
x = self.surface.size[0]/2-text.size[0]/2
|
||||||
|
if text.size[0] >= self.surface.size[0]-20:
|
||||||
|
x = self.surface.size[0]-text.size[0]-10
|
||||||
|
self.surface.blit(text,(x,self.surface.size[1]/2-text.size[1]/2))
|
||||||
|
|
||||||
if position != None:
|
if position != None:
|
||||||
if self.surface.rect(position[0],
|
if self.surface.rect(position[0],
|
||||||
position[1]).contains(_m.getPosition()[0],
|
position[1]).contains(_m.getPosition()[0],
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
@echo off
|
@echo off
|
||||||
python setup.py install
|
python setup.py install
|
||||||
echo [32mComplete![0m
|
echo [32mComplete![0m
|
||||||
pause >nul
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue