diff --git a/build/lib/pygwin/__main__.py b/build/lib/pygwin/__main__.py new file mode 100644 index 0000000..01ba041 --- /dev/null +++ b/build/lib/pygwin/__main__.py @@ -0,0 +1,8 @@ +import argparse + +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('args') +# parser.add_argument() + +args = parser.parse_args() +print(args.args) diff --git a/build/lib/pygwin/build.py b/build/lib/pygwin/build.py new file mode 100644 index 0000000..ca6c3ba --- /dev/null +++ b/build/lib/pygwin/build.py @@ -0,0 +1,7 @@ +import argparse + +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('args') + +args = parser.parse_args() +print(args.accumulate(args.args)) diff --git a/build/lib/pygwin/ui.py b/build/lib/pygwin/ui.py index 10a7891..e2d763f 100644 --- a/build/lib/pygwin/ui.py +++ b/build/lib/pygwin/ui.py @@ -211,13 +211,14 @@ class entry(widget): def insert(self,text): if _ct.WinDLL("User32.dll").GetKeyState(0x14): text = text.upper() - if _pg.key.get_pressed()[_pg.K_LSHIFT] or _pg.key.get_pressed()[_pg.K_RSHIFT]: - text = text.translate(dict(zip(map(ord, - '''1234567890-=[]\\;'''+"',./`"),'''!@#$%^&*()_+{}|:"<>?~'''))) if hex(getattr(_ct.windll.LoadLibrary("user32.dll"), "GetKeyboardLayout")(0))=='0x4190419': text = text.translate(dict(zip(map(ord, - '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'''), - '''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё'''))) + '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOPASDFGHJKLZXCVBNM'''), + '''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗФЫВАПРОЛДЯЧСМИТЬ'''))) + if _pg.key.get_pressed()[_pg.K_LSHIFT] or _pg.key.get_pressed()[_pg.K_RSHIFT]: + text = text.translate(dict(zip(map(ord, + u'''1234567890-=[]\;',./`'''), + u'''!@#$%^&*()_+{}|:"<>?~'''))) if text in self.blacklist: return if self.whitelist != None: diff --git a/dist/pgw-0.0.2-py3-none-any.whl b/dist/pgw-0.0.2-py3-none-any.whl index dc5b68c..13ae600 100644 Binary files a/dist/pgw-0.0.2-py3-none-any.whl and b/dist/pgw-0.0.2-py3-none-any.whl differ diff --git a/dist/pgw-0.0.2-py3.7.egg b/dist/pgw-0.0.2-py3.7.egg new file mode 100644 index 0000000..ca4da61 Binary files /dev/null and b/dist/pgw-0.0.2-py3.7.egg differ diff --git a/dist/pgw-0.0.2.tar.gz b/dist/pgw-0.0.2.tar.gz index 89842ae..a3e6b6c 100644 Binary files a/dist/pgw-0.0.2.tar.gz and b/dist/pgw-0.0.2.tar.gz differ diff --git a/dist/pgw-0.0.3-py3-none-any.whl b/dist/pgw-0.0.3-py3-none-any.whl new file mode 100644 index 0000000..cbd2d4d Binary files /dev/null and b/dist/pgw-0.0.3-py3-none-any.whl differ diff --git a/dist/pgw-0.0.3-py3.7.egg b/dist/pgw-0.0.3-py3.7.egg new file mode 100644 index 0000000..e9f05a1 Binary files /dev/null and b/dist/pgw-0.0.3-py3.7.egg differ diff --git a/dist/pgw-0.0.3.tar.gz b/dist/pgw-0.0.3.tar.gz new file mode 100644 index 0000000..ae892a7 Binary files /dev/null and b/dist/pgw-0.0.3.tar.gz differ diff --git a/examples/game.py b/examples/game.py index 4e3a7f2..4420654 100644 --- a/examples/game.py +++ b/examples/game.py @@ -1,42 +1,48 @@ -from random import randint -import pygwin as pgw +import pygwin # Importing pygwin +import random # Importing random -win = pgw.create('Game Example', (500,500)) +win = pygwin.create('A Simple Game', (500,500)) # Creating window -player = [250,250] -apple = pgw.rect(randint(0,490),randint(0,490),20,20) -count = 0 +player = [250,250] # Player position +apple = pygwin.rect(random.randint(0,490), + random.randint(0,490),20,20) # Apple rect +score = 0 # Player score -run = True -while run: - for event in pgw.getEvents(): - if event.type == pgw.QUIT: - run = False - win.fill((255,255,255)) - playerRect = pgw.rect(player[0]-10,player[1]-10,20,20) - win.draw.rect((0,0,0),playerRect) - win.draw.rect((200,50,50),apple) - win.blit(count,(0,0)) - if pgw.keyboard.isPressed('w'): - player[1] -= 5 - if pgw.keyboard.isPressed('s'): - player[1] += 5 - if pgw.keyboard.isPressed('d'): - player[0] += 5 - if pgw.keyboard.isPressed('a'): - player[0] -= 5 +run = True # Is loop running +while run: # Creating loop + for event in pygwin.getEvents(): # Events loop + if event.type == pygwin.QUIT: # If window quit + run = False # Break loop + win.fill((255,255,255)) # Fill window with color - if player[0] <= -10: - player[0] = 510 - if player[1] <= -10: - player[1] = 510 - if player[0] > 510: - player[0] = -10 - if player[1] > 510: - player[1] = -10 + playerRect = pygwin.rect(player[0]-10,player[1]-10,20,20) # Player rect + win.draw.rect((0,0,0),playerRect) # Drawing player rect + win.draw.rect((200,50,50),apple) # Drawing apple rect - if playerRect.collide(apple): - apple = pgw.rect(randint(0,490),randint(0,490),20,20) - count += 1 - win.update(60) -pgw.close() + win.blit(score,(0,0)) # Writing player score + + if pygwin.keyboard.isPressed('w'): # If keyboard key w pressed + player[1] -= 5 # Player position up + if pygwin.keyboard.isPressed('s'): # If keyboard key s pressed + player[1] += 5 # Player position down + if pygwin.keyboard.isPressed('d'): # If keyboard key d pressed + player[0] += 5 # Player position right + if pygwin.keyboard.isPressed('a'): # If keyboard key a pressed + player[0] -= 5 # Player position left + + if player[0] <= -10: # If player out of the screen (left) + player[0] = 510 # Set player position in right + if player[1] <= -10: # If player out of the screen (up) + player[1] = 510 # Set player position in down + if player[0] > 510: # If player out of the screen (right) + player[0] = -10 # Set player position in left + if player[1] > 510: # If player out of the screen (down) + player[1] = -10 # Set player position in up + + if playerRect.collide(apple): # If player rect collide apple rect + apple = pygwin.rect(random.randint(0,490), + random.randint(0,490),20,20) # Change apple rect + score += 1 # Update player score + + win.update(60) # Update window +pygwin.close() # Close pygwin diff --git a/examples/ui.py b/examples/ui.py index b76e076..8f3cc25 100644 --- a/examples/ui.py +++ b/examples/ui.py @@ -1,43 +1,43 @@ import pygwin win = pygwin.create('UI example',(270,350)) -base = pygwin.ui.base(win) +base = pygwin.ui.base(win) # Creating ui base -lbl = pygwin.ui.label('Label') -base.put(lbl,(130-(lbl.surface.size[0]/2),10)) -base.put(pygwin.ui.button('Button',width=250),(10,50)) -base.put(pygwin.ui.entry('Entry',width=123),(10,100)) -base.put(pygwin.ui.keySelect('Key',width=122),(138,100)) -loadbar = pygwin.ui.loadingBar(250,25) -base.put(loadbar,(10,150)) -slider = pygwin.ui.slider(250) -base.put(slider,(10,170)) -cb = pygwin.ui.checkBox(25,borderWidth=2) -base.put(cb,(10,220)) -base.put(pygwin.ui.label('Checkbox',20),(45,225)) -ta = pygwin.ui.textarea('Textarea',width=250,maxSymbols=20) -ta.text += '0123456789\n0123456789' -ta.focus = True -ta._generate() -ta.focus = False -base.put(ta,(10,255)) +lbl = pygwin.ui.label('Label') # Creating label +base.put(lbl,(130-(lbl.surface.size[0]/2),10)) # Putting label to base +base.put(pygwin.ui.button('Button',width=250),(10,50)) # Putting button to base +base.put(pygwin.ui.entry('Entry',width=123),(10,100)) # Putting entry to base +base.put(pygwin.ui.keySelect('Key',width=122),(138,100)) # Putting key selector to base +loadbar = pygwin.ui.loadingBar(250,25) # Creating loading bar +base.put(loadbar,(10,150)) # Putting loading bar to base +slider = pygwin.ui.slider(250) # Creating slider +base.put(slider,(10,170)) # Putting slider to base +cb = pygwin.ui.checkBox(25,borderWidth=2) # Creating checkbox +base.put(cb,(10,220)) # Putting checkbox to base +base.put(pygwin.ui.label('Checkbox',20),(45,225)) # Putting checkbox label to base +ta = pygwin.ui.textarea('Textarea',width=250,maxSymbols=20) # Creating textarea +ta.text += '0123456789\n0123456789' # Set text to textarea +ta.focus = True # Focus textarea +ta._generate() # Generate textarea surface +ta.focus = False # Unfocus textarea +base.put(ta,(10,255)) # Putting textarea to base tta = pygwin.ui.tip('textarea', *ta.surface.size, - waitBeforeShowing=30) -base.put(tta,(10,255)) + waitBeforeShowing=30) # Creating textarea tip +base.put(tta,(10,255)) # Putting textarea tip to base run = True while run: for event in pygwin.getEvents(): if event.type == pygwin.QUIT: run = False - base.draw() - if cb.get(): - loadbar.set(slider.get()) + base.draw() # Drawing base + if cb.get(): # If checkbox + loadbar.set(slider.get()) # If checkbox else: - loadbar.step() - if loadbar.get() == loadbar.length: - loadbar.set(0) - tta.responceWidth,tta.responceHeight=ta.surface.size + loadbar.step() # Step loading bar + if loadbar.get() == loadbar.length: # If loading bar is full + loadbar.set(0) # Reset loading bar + tta.responceWidth,tta.responceHeight=ta.surface.size # Set responce width, height to textarea tip win.update(30) pygwin.close() diff --git a/setup.cfg b/setup.cfg index 7d6a823..a9d2be4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pgw -version = 0.0.1 +version = 0.0.3 author = themixray author_email = simindeymo@gmail.com description = Python Grapchical Window. diff --git a/setup.py b/setup.py index b68e424..468f619 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -setup(name='pgw',packages=['pygwin'],version='0.0.1',author='themixray', +setup(name='pgw',packages=['pygwin'],version='0.0.3',author='themixray', description='A library for creating Python applications.', license='MIT',install_requires=['cython','pywin32','pygame', 'inputs','pydub','wxPython','pyautogui']) diff --git a/src/pgw.egg-info/PKG-INFO b/src/pgw.egg-info/PKG-INFO new file mode 100644 index 0000000..63827af --- /dev/null +++ b/src/pgw.egg-info/PKG-INFO @@ -0,0 +1,31 @@ +Metadata-Version: 2.1 +Name: pgw +Version: 0.0.3 +Summary: A library for creating Python applications. +Home-page: https://github.com/themixray/pygwin +Author: themixray +Author-email: simindeymo@gmail.com +License: MIT +Project-URL: Bug Tracker, https://github.com/themixray/pygwin/issues +Project-URL: Wiki, https://github.com/themixray/pygwin/wiki +Platform: UNKNOWN +Classifier: Programming Language :: Python :: 3 +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Description-Content-Type: text/markdown +License-File: LICENSE + +

+ PyGWin +

+

+ A library for creating Python applications. +

+ +

+ + Documentation + +

+ + diff --git a/src/pgw.egg-info/SOURCES.txt b/src/pgw.egg-info/SOURCES.txt new file mode 100644 index 0000000..9fa79f3 --- /dev/null +++ b/src/pgw.egg-info/SOURCES.txt @@ -0,0 +1,24 @@ +LICENSE +README.md +pyproject.toml +setup.cfg +setup.py +src/pgw.egg-info/PKG-INFO +src/pgw.egg-info/SOURCES.txt +src/pgw.egg-info/dependency_links.txt +src/pgw.egg-info/requires.txt +src/pgw.egg-info/top_level.txt +src/pygwin/__init__.py +src/pygwin/_pg.py +src/pygwin/_win.py +src/pygwin/console.py +src/pygwin/font.py +src/pygwin/gamepad.py +src/pygwin/image.py +src/pygwin/keyboard.py +src/pygwin/mixer.py +src/pygwin/mouse.py +src/pygwin/rect.py +src/pygwin/surface.py +src/pygwin/tray.py +src/pygwin/ui.py \ No newline at end of file diff --git a/src/pgw.egg-info/dependency_links.txt b/src/pgw.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/pgw.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/src/pgw.egg-info/requires.txt b/src/pgw.egg-info/requires.txt new file mode 100644 index 0000000..569ce2e --- /dev/null +++ b/src/pgw.egg-info/requires.txt @@ -0,0 +1,7 @@ +cython +pywin32 +pygame +inputs +pydub +wxPython +pyautogui diff --git a/src/pgw.egg-info/top_level.txt b/src/pgw.egg-info/top_level.txt new file mode 100644 index 0000000..9907c64 --- /dev/null +++ b/src/pgw.egg-info/top_level.txt @@ -0,0 +1 @@ +pygwin diff --git a/src/pygwin/font.py b/src/pygwin/font.py index 4532537..615ae8a 100644 --- a/src/pygwin/font.py +++ b/src/pygwin/font.py @@ -30,7 +30,7 @@ class font: surface._surface_orig = surf return surface def size(self, text, size, newLineSpace=5, - italic=False, bold=False, underline=False): + italic=False,bold=False,underline=False): return self.render(text, size, (255,255,255), newLineSpace=newLineSpace, italic=italic, bold=bold, diff --git a/src/pygwin/ui.py b/src/pygwin/ui.py index 70f4ddf..e2d763f 100644 --- a/src/pygwin/ui.py +++ b/src/pygwin/ui.py @@ -211,12 +211,14 @@ class entry(widget): def insert(self,text): if _ct.WinDLL("User32.dll").GetKeyState(0x14): text = text.upper() - if _pg.key.get_pressed()[_pg.K_LSHIFT] or _pg.key.get_pressed()[_pg.K_RSHIFT]: - text = text.translate(dict(zip(map(ord, '''1234567890-=[]\\;'''+"',./`"), - '''!@#$%^&*()_+{}|:"<>?~'''))) if hex(getattr(_ct.windll.LoadLibrary("user32.dll"), "GetKeyboardLayout")(0))=='0x4190419': - text = text.translate(dict(zip(map(ord, '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'''), - '''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё'''))) + text = text.translate(dict(zip(map(ord, + '''qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOPASDFGHJKLZXCVBNM'''), + '''йцукенгшщзхъфывапролджэячсмитьбю.ёЙЦУКЕНГШЩЗФЫВАПРОЛДЯЧСМИТЬ'''))) + if _pg.key.get_pressed()[_pg.K_LSHIFT] or _pg.key.get_pressed()[_pg.K_RSHIFT]: + text = text.translate(dict(zip(map(ord, + u'''1234567890-=[]\;',./`'''), + u'''!@#$%^&*()_+{}|:"<>?~'''))) if text in self.blacklist: return if self.whitelist != None: @@ -304,8 +306,10 @@ class textarea(widget): self.tick += 1 if self.tick >= 60: if self.text != '': - points = [[x+self.font.size(last,self.fontSize)[0],self.surface.size[1]-(self.font.size('X',self.fontSize)[1])], - [x+self.font.size(last,self.fontSize)[0],self.surface.size[1]/2-text.size[1]/2+self.surface.size[1]-10]] + points = [[x+self.font.size(last,self.fontSize)[0], + self.surface.size[1]-(self.font.size('X',self.fontSize)[1])], + [x+self.font.size(last,self.fontSize)[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 @@ -355,9 +359,11 @@ class textarea(widget): if _pg.key.get_pressed()[_pg.K_LSHIFT] or _pg.key.get_pressed()[_pg.K_RSHIFT]: text = text.translate(dict(zip(map(ord, '''1234567890-=[]\\;'''+"',./`"), '''!@#$%^&*()_+{}|:"<>?~'''))) - 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 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: @@ -612,15 +618,19 @@ class checkBox(widget): self.surface.size[0]-self.borderWidth*2, self.surface.size[1]-self.borderWidth*2)) if self.x: - self.surface.draw.line(self.afg,[self.borderWidth,self.width/2+self.borderWidth],[self.width/2,self.width-self.borderWidth],self.borderWidth) - self.surface.draw.line(self.afg,[self.width/2,self.width-self.borderWidth],[self.width-self.borderWidth,self.borderWidth],self.borderWidth) + self.surface.draw.line(self.afg,[self.borderWidth,self.width/2+self.borderWidth], + [self.width/2,self.width-self.borderWidth],self.borderWidth) + self.surface.draw.line(self.afg,[self.width/2,self.width-self.borderWidth], + [self.width-self.borderWidth,self.borderWidth],self.borderWidth) 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.x: - self.surface.draw.line(self.fg,[self.borderWidth,self.width/2+self.borderWidth],[self.width/2,self.width-self.borderWidth],self.borderWidth) - self.surface.draw.line(self.fg,[self.width/2,self.width-self.borderWidth],[self.width-self.borderWidth,self.borderWidth],self.borderWidth) + self.surface.draw.line(self.fg,[self.borderWidth,self.width/2+self.borderWidth], + [self.width/2,self.width-self.borderWidth],self.borderWidth) + self.surface.draw.line(self.fg,[self.width/2,self.width-self.borderWidth], + [self.width-self.borderWidth,self.borderWidth],self.borderWidth) def draw(self, win, pos): self._generate(pos) win.blit(self.surface,pos) @@ -633,6 +643,51 @@ class checkBox(widget): # def draw(self, win, pos): # self._generate(pos) # win.blit(self.surface,pos) +class tip(widget): + def __init__(self,text,responceWidth,responceHeight,fontSize=15,font=_df, + borderColor=(180,180,50),borderWidth=2,bg=(255,255,128), + fg=(35,35,5),waitBeforeShowing=0, + tipPosRelativeCursor=(10,10)): + super()._args(locals()) + self.tick = -1 + self.lcp = (0,0) + self.tprc = self.tipPosRelativeCursor + self._generate() + def _generate(self, position=None): + self.surface = _s((self.responceWidth, + self.responceHeight)) + if position != None: + self.tick += 1 + if self.lcp != _m.getPosition(): + self.tick = 0 + self.lcp = _m.getPosition() + if self.tick >= self.waitBeforeShowing: + mp = _m.getPosition() + mp = [mp[0]+self.tprc[0]-position[0], + mp[1]+self.tprc[1]-position[1]] + rect = _r(mp[0],mp[1], + self.font.size(self.text,self.fontSize)[0]+4, + self.font.size(self.text,self.fontSize)[1]+6) + if mp[0]<0 or mp[1]<0:return + if mp[0]>self.responceWidth:return + if mp[1]>self.responceHeight:return + if mp[0]>self.responceWidth-rect.w: + mp[0]=self.responceWidth-rect.w + if mp[1]>self.responceHeight-rect.h: + mp[1]=self.responceHeight-rect.h + rect = _r(mp[0],mp[1], + self.font.size(self.text,self.fontSize)[0]+4, + self.font.size(self.text,self.fontSize)[1]+6) + self.surface.draw.rect(self.bg,rect) + self.surface.draw.rect( + self.borderColor,rect,self.borderWidth) + ts = self.font.render( + self.text,self.fontSize,self.fg) + self.surface.blit(ts,(mp[0]+2,mp[1]+3)) + def draw(self, win, pos): + self._generate(pos) + win.blit(self.surface,pos) + class base: def __init__(self, win, bg=(128,128,128)): self._widgets = {}