Add files via upload

This commit is contained in:
themixray 2021-11-10 19:26:52 +03:00 committed by GitHub
parent acc18cd6e4
commit c90e4875ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1523 additions and 5 deletions

19
LICENSE Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,5 +1,4 @@
![Logo](https://github.com/themixray/pygwin/blob/01a4c25d6e75a139a77ab19d0137b8445132e011/logo.png) # PyGWin
# PyGWin A library for creating Python applications.
A library for creating Python applications.
[Documentation](https://github.com/themixray/pygwin/wiki)
[Documentation](https://github.com/themixray/pygwin/wiki)

BIN
dist/pygwin0-0.0.1-py3-none-any.whl vendored Normal file

Binary file not shown.

BIN
dist/pygwin0-0.0.1.tar.gz vendored Normal file

Binary file not shown.

13
pyproject.toml Normal file
View file

@ -0,0 +1,13 @@
[build-system]
requires = [
"pydub",
"pygame",
"pywin32",
"requests",
"pyautogui",
"inputs",
"pillow",
"wxPython",
"setuptools >=42"
]
build-backend = "setuptools.build_meta"

21
setup.cfg Normal file
View file

@ -0,0 +1,21 @@
[metadata]
name = pygwin0
version = 0.0.1
author = themixray
author_email = simindeymo@gmail.com
description = A library for creating Python applications.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/themixray/pygwin
project_urls =
Bug Tracker = https://github.com/themixray/pygwin/issues
Wiki = https://github.com/themixray/pygwin/wiki
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
package_dir =
= src
packages = find:

15
src/pygwin/__init__.py Normal file
View file

@ -0,0 +1,15 @@
from pygwin.surface import surface
import pygwin.keyboard as keyboard
from pygwin.console import console
import pygwin.gamepad as _gp
import pygwin.mouse as mouse
from pygwin.rect import rect
import pygwin.image as image
import pygwin.mixer as mixer
from pygwin.tray import tray
from pygame.locals import *
import pygwin.font as font
from pygwin._win import *
from pygwin._pg import pg
import pygwin.ui as ui
gamepad = _gp.gamepad(pg)

16
src/pygwin/_pg.py Normal file
View file

@ -0,0 +1,16 @@
from contextlib import contextmanager as _cm
import os as _os
import sys as _sys
@_cm
def _suppress_stdout():
with open(_os.devnull, "w") as devnull:
old_stdout = _sys.stdout
_sys.stdout = devnull
try:
yield
finally:
_sys.stdout = old_stdout
with _suppress_stdout():
import pygame as pg
pg.init()

138
src/pygwin/_win.py Normal file
View file

@ -0,0 +1,138 @@
from pygwin.surface import surface as _surface
from pygwin.tray import tray as _tray
from datetime import datetime as _dt
from pygwin.image import save as _s
from pygwin._pg import pg as _pg
import pygwin.image as _img
import win32job as _w32j
import win32api as _w32a
import win32con as _w32c
import win32gui as _w32g
import requests as _req
import tempfile as _tf
import pickle as _p
class win(_surface):
def __init__(self, iconpath=None):
self._orig = _pg.display.get_surface()
super().__init__(self._orig.get_size())
self._orig = _pg.display.get_surface()
self._clock = _pg.time.Clock()
self._withfps = False
self._iconpath = iconpath
if iconpath != None:
self.tray = _tray(self.title,iconpath)
def update(self, fps=-1):
if fps != -1:
self._clock.tick(fps)
self._withfps = True
_pg.display.update()
def title():
def fget(self):
return _pg.display.get_caption()[0]
def fset(self, value):
if type(value) != str:
return
_pg.display.set_caption(value)
def fdel(self):
pass
return locals()
title = property(**title())
def icon(value):
_pg.display.set_icon(_pg.image.load(value))
self._iconpath = iconpath
def size():
def fget(self):
return _pg.display.get_window_size()
def fset(self, value):
if type(value) in [list,tuple]:
return
_pg.display.set_mode(value)
def fdel(self):
pass
return locals()
size = property(**size())
def fullscreen(self):
_pg.display.toogle_fullscreen()
def close(self):
_pg.display.quit()
_w32g.PostMessage(self.hwnd, _w32c.WM_CLOSE, 0, 0)
self.tray.stop()
def focus(self):
self.hide()
self.show()
_w32g.BringWindowToTop(self.hwnd)
_w32g.ShowWindow(self.hwnd, _w32c.SW_SHOWNORMAL)
_w32g.SetForegroundWindow(self.hwnd)
def unfocus(self):
pass
def hide(self):
_w32g.ShowWindow(self.hwnd, _w32c.SW_HIDE)
def show(self):
_w32g.ShowWindow(self.hwnd, _w32c.SW_SHOW)
def move(self, x, y):
rect = _w32g.GetWindowRect(self.hwnd)
_w32g.MoveWindow(self.hwnd, x, y, rect[2]-x, rect[3]-y, 0)
def screenshot(self, path):
_s(self._orig, path)
return path
@property
def position(self):
rect = _w32g.GetWindowRect(self.hwnd)
x = rect[0]
y = rect[1]
return (x, y)
@property
def rawFps(self):
if self._withfps:
return self._clock.get_fps()
else:
return float(f'2010.{_dt.now().year}')
@property
def fps(self):
return int(self.rawFps)
@property
def hwnd(self):
return _pg.display.get_wm_info()['window']
@property
def visible(self):
return _w32g.IsWindowVisible(self._win)
def create(title=None, size=(0,0), icon=None, resizable=False, noframe=False):
screen = _pg.display.set_mode(size)
if resizable:
screen = _pg.display.set_mode(size,_pg.RESIZABLE)
if noframe:
screen = _pg.display.set_mode(size,_pg.NOFRAME)
else:
if title != None:
_pg.display.set_caption(title)
if icon != None:
_pg.display.set_icon(_pg.image.load(icon))
return win(icon)
def ramLimit(memory_limit):
hjob = _w32j.CreateJobObject(None,job_name)
if breakaway:
info = _w32j.QueryInformationJobObject(hjob,_w32j.JobObjectExtendedLimitInformation)
if breakaway=='silent':info['BasicLimitInformation']['LimitFlags']|=(_w32j.JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK)
else:info['BasicLimitInformation']['LimitFlags']|=(_w32j.JOB_OBJECT_LIMIT_BREAKAWAY_OK)
_w32j.SetInformationJobObject(hjob,_w32j.JobObjectExtendedLimitInformation,info)
hprocess = _w32a.GetCurrentProcess()
try:_w32j.AssignProcessToJobObject(hjob, hprocess);g_hjob=hjob
except _w32j.error as e:
if e.winerror!=winerror.ERROR_ACCESS_DENIED:raise
elif sys.getwindowsversion()>=(6,2):raise
elif _w32j.IsProcessInJob(hprocess,None):raise
warnings.warn('The process is already in a job. Nested jobs are not supported prior to Windows 8.')
info=_w32j.QueryInformationJobObject(g_hjob,_w32j.JobObjectExtendedLimitInformation)
info['ProcessMemoryLimit']=memory_limit
info['BasicLimitInformation']['LimitFlags']|=(_w32j.JOB_OBJECT_LIMIT_PROCESS_MEMORY)
_w32j.SetInformationJobObject(g_hjob,_w32j.JobObjectExtendedLimitInformation,info)
def close():
_pg.quit()
quit()
def getEvents():
return _pg.event.get()

62
src/pygwin/console.py Normal file
View file

@ -0,0 +1,62 @@
import win32console as w32con
import win32con as w32c
import win32gui as w32g
import pyautogui as pag
class console:
def __init__(self):
self._hwnd = w32con.GetConsoleWindow()
@property
def hwnd(self):
return self._hwnd
def focus(self):
self.hide()
self.show()
w32g.BringWindowToTop(self.hwnd)
w32g.ShowWindow(self.hwnd, w32c.SW_SHOWNORMAL)
w32g.SetForegroundWindow(self.hwnd)
def unfocus(self):
pass
def hide(self):
w32g.ShowWindow(self.hwnd, w32c.SW_HIDE)
def show(self):
w32g.ShowWindow(self.hwnd, w32c.SW_SHOW)
def move(self, x, y):
w32g.SetWindowPos(self.hwnd, x, y, self.size[0], self.size[1])
def resize(self, width, height):
w32g.SetWindowPos(self.hwnd, self.position[0], self.position[1], width, height)
def minimize(self):
w32g.ShowWindow(hwnd, w32c.SW_MINIMIZE)
return self.size
def maximize(self):
w32g.ShowWindow(hwnd, w32c.SW_MAXIMIZE)
return self.size
def title():
def fget(self):
return w32con.GetConsoleTitle()
def fset(self, value):
w32con.SetConsoleTitle(str(value))
def fdel(self):
pass
return locals()
title = property(**title())
@property
def visible(self):
return w32g.IsWindowVisible(self.hwnd)
@property
def position(self):
rect = w32g.GetWindowRect(self.hwnd)
x = rect[0]+7
y = rect[1]
return (x, y)
@property
def size(self):
rect = w32g.GetWindowRect(self.hwnd)
w = rect[2] - self.position[0]-7
h = rect[3] - self.position[1]-7
return (w, h)
def screenshot(self, path):
rect = self.position+self.size
self.focus()
pag.screenshot(path, region=rect)
return path

43
src/pygwin/font.py Normal file
View file

@ -0,0 +1,43 @@
from pygwin.surface import surface as _surface
from pygwin._pg import pg as _pg
class font:
def __init__(self, path):
self._path = path
def _font(self, size):
return _pg.font.Font(self._path,size)
def render(self, text, size, color, newLineSpace=5,
italic=False, bold=False, underline=False):
text = str(text)
font = self._font(size)
font.set_italic(italic)
font.set_bold(bold)
font.set_underline(underline)
if text.replace('\n', '') != text:
text = text.split('\n')
surf = _pg.Surface([font.size(max(text,key=lambda x:font.size(x)[0]))[0],
(font.size('123')[1]+newLineSpace)*len(text)],_pg.SRCALPHA)
y = 0
for i in text:
r = font.render(i, True, color)
surf.blit(r, (0, y))
y += font.size(i)[1]
if i != text[-1]:
y += newLineSpace
else:
surf = font.render(text, True, color)
surface = _surface(surf.get_size())
surface._surface_orig = surf
return surface
def size(self, text, size, newLineSpace=5,
italic=False, bold=False, underline=False):
return self.render(text, size, (255,255,255),
newLineSpace=newLineSpace,
italic=italic, bold=bold,
underline=underline).size
class sysFont(font):
def __init__(self, name):
self._path = _pg.font.match_font(name)
defaultFont = font(_pg.font.get_default_font())

111
src/pygwin/gamepad.py Normal file
View file

@ -0,0 +1,111 @@
import inputs as _inputs
import threading as _threading
import time as _time
class gamepad:
def __init__(self, pygame):
self._lasty = ''
self._lastx = ''
self.founded = False
self._buttons = {'left-joystick': False,
'right-joystick': False,
'north': False,
'south': False,
'west': False,
'east': False,
'l1': False,
'l2': False,
'r1': False,
'r2': False,
'up': False,
'down': False,
'left': False,
'right': False,
'start': False,
'select': False}
self.leftJoystick = [0, 0]
self.rightJoystick = [0, 0]
self._pygame = pygame
self._start()
def _tick(self):
events = _inputs.get_gamepad()
if not self._pygame.display.get_active():
return
self.founded = True
if events:
for event in events:
if event.code == 'ABS_X':
self.leftJoystick[0] = event.state
elif event.code == 'ABS_Y':
self.leftJoystick[1] = event.state
elif event.code == 'ABS_RY':
self.rightJoystick[1] = event.state
elif event.code == 'ABS_RX':
self.rightJoystick[0] = event.state
elif event.code == 'BTN_THUMBL':
self._buttons['left-joystick'] = event.state
elif event.code == 'BTN_THUMBR':
self._buttons['right-joystick'] = event.state
elif event.code == 'BTN_TL':
self._buttons['l1'] = event.state
elif event.code == 'BTN_TR':
self._buttons['r1'] = event.state
elif event.code == 'ABS_Z':
if event.state == 255:
self._buttons['l2'] = 1
elif event.state == 0:
self._buttons['l2'] = 0
elif event.code == 'ABS_RZ':
if event.state == 255:
self._buttons['r2'] = 1
elif event.state == 0:
self._buttons['r2'] = 0
elif event.code == 'BTN_WEST':
self._buttons['west'] = event.state
elif event.code == 'BTN_NORTH':
self._buttons['north'] = event.state
elif event.code == 'BTN_EAST':
self._buttons['east'] = event.state
elif event.code == 'BTN_SOUTH':
self._buttons['south'] = event.state
elif event.code == 'ABS_HAT0Y':
if event.state == 1:
self._buttons['down'] = True
self._lasty = 'down'
elif event.state == -1:
self._buttons['up'] = True
self._lasty = 'up'
else:
self._buttons[self._lasty] = False
elif event.code == 'ABS_HAT0X':
if event.state == 1:
self._buttons['right'] = True
self._lastx = 'right'
elif event.state == -1:
self._buttons['left'] = True
self._lastx = 'left'
else:
self._buttons[self._lastx] = False
elif event.code == 'BTN_START':
self._buttons['select'] = event.state
elif event.code == 'BTN_SELECT':
self._buttons['start'] = event.state
def _start(self):
self.founded = False
self._started = True
def ttcb(self):
while self._started:
self._tick()
_threading.Thread(target=lambda:ttcb(self),daemon=True).start()
def close(self):
self._started = False
def isPressed(self, btn):
return btn in self._buttons
def reset(self):
self._lasty = ''
self._lastx = ''
self._buttons = []
self.leftJoystick = [0, 0]
self.rightJoystick = [0, 0]
def getPressed(self):
return self._buttons

44
src/pygwin/image.py Normal file
View file

@ -0,0 +1,44 @@
from pygwin._pg import pg as _pg
from pygwin.surface import surface as _surface
from PIL import Image as _im
import pickle as _p
import bz2 as _bz2
def load(path):
if path.endswith('.gif'):
im = _im.open(path)
surfs = []
for i in range(im.n_frames):
im.seek(i)
image = _pg.image.fromstring(im.tobytes(),im.size,im.mode)
surf = _surface(image.get_size())
surf._surface_orig = image
surfs.append(surf)
return surfs
else:
im = _im.open(path.encode('utf8').decode('utf8'))
image = _pg.image.fromstring(im.tobytes(),im.size,im.mode)
surf = _surface(im.size)
surf.blit(image,(0,0))
return surf
def save(surface, dest):
if type(surface) == _surface:
orig = surface._surface_orig
else:
orig = surface._orig
_pg.image.save_extended(orig, dest)
def toBytes(surface):
try:
orig = surface._surface_orig
except:
orig = surface._orig
return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)]))
def fromBytes(bytes):
string = _p.loads(_bz2.decompress(bytes))
surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA")
surface = _surface(tuple(string[1]))
surface.blit(surf,(0,0))
return surface

10
src/pygwin/keyboard.py Normal file
View file

@ -0,0 +1,10 @@
from pygwin._pg import pg as _pg
def getPressed():
fkeys = {}
keys = _pg.key.get_pressed()
for i in range(len(keys)):
fkeys.update({_pg.key.name(i):keys[i]})
return fkeys
def isPressed(key):
return getPressed()[key]

92
src/pygwin/mixer.py Normal file
View file

@ -0,0 +1,92 @@
from pygwin._pg import pg as _pg
import os as _os
import tempfile as _tf
ffmpeg = None
class sound:
def __init__(self, path):
if not (path.endswith('.wav') or path.endswith('.ogg')):
try:
from pydub import AudioSegment as _as
if ffmpeg != None:
_as.ffmpeg = ffmpeg
_as.converter = ffmpeg
sound = _as.from_file(path, _os.path.splitext(path)[1])
path = _tf.mkstemp('.wav')
sound.export(path, format="wav")
except:
print('Set ffmpeg to path so that you don'+\
"'t have to convert the file to "+\
'".wav". If you have installed, but the error still appears, write down the path to ffmpeg.exe in plugin.ffmpeg.')
self._sound = _pg.mixer.Sound(path)
def play(self):
self._sound.play()
def stop(self):
self._sound.stop()
def volume():
def fget(self):
return self._sound.get_volume()
def fset(self, value):
if type(value) == int:
self._sound.set_volume(value)
def fdel(self):
pass
return locals()
volume = property(**volume())
@property
def length(self):
return self._sound.get_length()
class music:
def __init__(self, path):
if path.endswith('.wav') or path.endswith('.ogg'):
self._path = path
else:
try:
from pydub import AudioSegment as _as
if ffmpeg != None:
_as.ffmpeg = ffmpeg
_as.converter = ffmpeg
sound = _as.from_file(path, _os.path.splitext(path)[1])
path = _tf.mkstemp('.wav')
sound.export(path, format="wav")
except:
print('Set ffmpeg to path so that you don'+\
"'t have to convert the file to "+\
'".wav". If you have installed, but the error still appears, write down the path to ffmpeg.exe in plugin.ffmpeg.')
_pg.mixer.music.load(path)
def play(self, loops=0):
_pg.mixer.music.play(loops)
def stop(self):
_pg.mixer.music.stop()
def restart(self):
_pg.mixer.music.rewind()
def pause(self):
_pg.mixer.music.pause()
def release(self):
_pg.mixer.music.unpause()
def queue(self):
_pg.mixer.music.queue(self._path)
def volume():
def fget(self):
return _pg.mixer.music.get_volume()
def fset(self, value):
if type(value) == int:
_pg.mixer.music.set_volume(value)
def fdel(self):
pass
return locals()
volume = property(**volume())
def pos():
def fget(self):
return _pg.mixer.music.get_pos()
def fset(self, value):
if type(value) == int:
_pg.mixer.music.set_pos(value)
def fdel(self):
pass
return locals()
pos = property(**pos())

22
src/pygwin/mouse.py Normal file
View file

@ -0,0 +1,22 @@
from pygwin._pg import pg as _pg
def getPressed():
orig = _pg.mouse.get_pressed(3)
return {'left':orig[0],'middle':orig[1],'right':orig[2]}
def isPressed(x):
return getPressed()[x]
def setPosition(x):
_pg.mouse.set_pos(x)
def getPosition():
return _pg.mouse.get_pos()
def setVisible(x):
_pg.mouse.set_visible(x)
def getVisible():
return _pg.mouse.get_visible()
def getCursor():
return _pg.mouse.get_cursor()
def setCursor(size, hotspot=None, xormasks=None, andmasks=None):
if hotspot == None and xormasks == None and andmasks == None:
_pg.mouse.set_system_cursor(size)
else:
_pg.mouse.set_cursor(size, hotspot, xormasks, andmasks)

31
src/pygwin/rect.py Normal file
View file

@ -0,0 +1,31 @@
from pygwin._pg import pg
class rect:
def __init__(self,x,y,w,h):
self.x = x
self.y = y
self.w = w
self.h = h
self._rect = pg.Rect(x,y,w,h)
def width():
def fget(self):
return self.w
def fset(self, value):
self.w = value
def fdel(self):
pass
return locals()
width = property(**width())
def height():
def fget(self):
return self.h
def fset(self, value):
self.h = value
def fdel(self):
pass
return locals()
height = property(**height())
def collide(self, x):
return self._rect.colliderect(x._rect_rect)
def contains(self, x, y):
return self._rect.collidepoint(x,y)

142
src/pygwin/surface.py Normal file
View file

@ -0,0 +1,142 @@
from pygwin.rect import rect as _r
from pygwin._pg import pg as _pg
class surface:
def __init__(self, size):
self._size = size
self._orig = _pg.Surface(size, _pg.SRCALPHA)
@property
def pixels(self):
pixels = []
pxls = _pg.PixelArray(self._orig)
for x in range(self.size[0]):
pixels.append([])
for y in range(self.size[1]):
pixels[x].append(pxls[x, y])
return pixels
@property
def size(self):
return self._size
def rect(self, x=0, y=0, center=[]):
if center == []:
return _r(x, y, self.size[0], self.size[1])
else:
return _r(center[0]-(self.size[0]/2),
center[1]-(self.size[1]/2),
self.size[0], self.size[1])
def copy(self):
surf = surface(self._size)
surf._surface_orig = self._orig
surf._surface_size = self._size
return surf
def getPixel(self, x, y):
return self._orig.get_at((x,y))
def setPixel(self, x, y, color):
self._orig.set_at((x,y),color)
return self.copy()
def blit(self, surf, xy):
if type(surf) != surface and type(surf) != _pg.Surface:
from pygwin.font import defaultFont as _df
surf = _df.render(surf, 25, (0,0,0))
try:
self._orig.blit(surf._surface_orig, xy)
except:
try:
self._orig.blit(surf._orig, xy)
except:
self._orig.blit(surf, xy)
return self.copy()
def fill(self, color):
self._orig.fill(color)
return self.copy()
def crop(self, rect):
self._orig = self._orig.subsurface((rect.x,rect.y,rect.w,rect.h))
self._size = self._orig.get_size()
return self.copy()
def scale(self, size, smooth=False):
if not smooth:
self._orig = _pg.transform.scale(self._orig, size)
else:
self._orig = _pg.transform.smoothscale(self._orig, size)
self._size = self._orig.get_size()
return self.copy()
def rotate(self, angle):
self._orig = _pg.transform.rotate(self._orig, angle)
self._size = self._orig.get_size()
return self.copy()
def flip(self, x, y):
self._orig = _pg.transform.flip(self._orig, x, y)
return self.copy()
def blur(self, amt):
if amt < 0:return self.copy()
scale = (int(self._orig.get_width()*(amt+1)),
int(self._orig.get_height()*(amt+1)))
size = self._orig.get_size()
self._orig = _pg.transform.smoothscale(self._orig,scale)
self._orig = _pg.transform.smoothscale(self._orig,size)
return self.copy()
class _draw:
def __init__(self,surface):
self._surf = surface
def rect(self,color,rect,
width=0,borderRadius=0,
borderTopLeftRadius=-1,
borderTopRightRadius=-1,
borderBottomLeftRadius=-1,
borderBottomRightRadius=-1):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.rect(orig,color,_pg.Rect(rect.x,rect.y,rect.w,rect.h),
width,borderRadius,borderTopLeftRadius,
borderTopRightRadius,borderBottomLeftRadius,
borderBottomRightRadius)
return self._surf.copy()
def polygon(self, color, points, width=0):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.polygon(orig,color,points,width)
return self._surf.copy()
def circle(self,color,center,
radius,width=0,
drawTopLeft=1,
drawTopRight=1,
drawBottomLeft=1,
drawBottomRight=1):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.circle(orig,color,center,radius,
width,drawTopRight,drawTopLeft,
drawBottomLeft,drawBottomRight)
return self._surf.copy()
def ellipse(self,color,rect,width=0):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.ellipse(orig,color,_pg.Rect(rect.x,rect.y,rect.w,rect.h),width)
return self._surf.copy()
def line(self,color,start,end,width=1):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.line(orig,color,start,end,width)
return self._surf.copy()
def arc(self,color,rect,startAngle,stopAngle,width=1):
try:
orig = self._surf._surface_orig
except:
orig = self._surf._orig
_pg.draw.arc(orig,color,
_pg.Rect(rect.x,rect.y,rect.w,rect.h),
startAngle,stopAngle,width)
return self._surf.copy()
@property
def draw(self):
return self._draw(self)

49
src/pygwin/tray.py Normal file
View file

@ -0,0 +1,49 @@
import threading
import wx
import wx.adv
from pygwin._pg import pg
import copy
class tray(wx.adv.TaskBarIcon):
def __init__(self, tooltip, iconpath):
class App(wx.App):
def OnInit(self):
self.frame = wx.Frame(None)
self.SetTopWindow(self.frame)
return True
self._app = App(False)
self.frame = self._app.frame
super().__init__()
self._tooltip = tooltip
self._iconpath = iconpath
self.setIcon(iconpath)
self._menu = wx.Menu()
def CreatePopupMenu(self):
return self._menu
def GetPopupMenu(self):
return self._menu
def setIcon(self, path):
self._bicon = wx.Icon(wx.Bitmap(path))
self.SetIcon(self._bicon, self._tooltip)
def setTooltip(self, tooltip):
self.SetIcon(self._bicon, tooltip)
self._tooltip = tooltip
def onLeftMouseButton(self):
pass
def addSeparator(self):
self._menu.AppendSeparator()
def addCommand(self,text,func=lambda:None):
item = wx.MenuItem(self._menu,-1,text)
self._menu.Bind(wx.EVT_MENU,
lambda x:func(),
id=item.GetId())
self._menu.Append(item)
def start(self, thread=True):
cbotld = lambda x:self.onLeftMouseButton()
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN,cbotld)
if thread: threading.Thread(
target=self._app.MainLoop,
daemon=1).start()
else: self._app.MainLoop()
def stop(self):
wx.CallAfter(self._app.frame.Close)

651
src/pygwin/ui.py Normal file
View file

@ -0,0 +1,651 @@
from pygwin._pg import pg as _pg
from pygwin.surface import surface as _s
from pygwin.font import defaultFont as _df
from pygwin.image import load as _l
from pygwin.rect import rect as _r
import pygwin.mouse as _m
import pygwin.keyboard as _k
import ctypes as _ct
import copy as _copy
class widget:
power = True
destroyed = False
def _args(self, locals):
args = _copy.copy(locals)
for i in args.items():
if i[0] != 'self':
exec(f'self.{i[0]} = args["{i[0]}"]')
self._args = args
def __init__(self, surface):
self._args(locals())
def draw(self, win, pos):
win.blit(self.surface,pos)
def on(self):
self.power = True
def off(self):
self.power = False
def destroy(self):
self.destroyed = True
def config(self, **parameters):
if parameters != {}:
for i in parameters.items():
if i[0] in list(self.__dict__.keys()):
exec(f'self.{i[0]} = parameters["{i[0]}"]')
self._args[i[0]] = i[1]
else:
return self._args
self.__init__(**self._args)
class button(widget):
def __init__(self,text,
func=lambda:None,
fontSize=30,font=_df,
width=None,height=None,
bg=(70,70,70),fg=(180,180,200),
afg=(50,50,50),abg=(200,200,200),
borderColor=(50,50,50),borderWidth=5):
super()._args(locals())
self.cl0 = False
self.cl1 = False
self.nc0 = True
self._generate()
def _generate(self, position=None):
if self.width == None or self.height == None:
textSize = self.font.size(self.text,self.fontSize)
if self.width != None:
self.surface = _s((self.width,textSize[1]+10))
elif self.height != None:
self.surface = _s((textSize[0]+50,self.height))
else:
self.surface = _s((textSize[0]+50,textSize[1]+10))
else:
self.surface = _s((self.width,self.height))
if position != None:
contains = self.surface.rect(position[0], position[1]).contains(
_m.getPosition()[0], _m.getPosition()[1])
cacm = contains and _m.isPressed('left')
else:
contains = False
cacm = False
if contains and not self.cl0:
_m.setCursor(_pg.SYSTEM_CURSOR_HAND)
self.cl0 = True
self.nc0 = True
elif not contains:
if self.nc0:
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
self.nc0 = False
self.cl0 = False
if cacm and not self.cl1:
self.func()
self.cl1 = True
elif not cacm:
self.cl1 = False
self.surface.fill(self.borderColor)
if cacm:
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))
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 cacm:
text = self.font.render(self.text,self.fontSize,self.afg)
else:
text = self.font.render(self.text,self.fontSize,self.fg)
pos = text.rect(center=(
self.surface.size[0]/2,
self.surface.size[1]/2))
pos = [pos.x, pos.y]
self.surface.blit(text,pos)
def draw(self, win, pos):
self._generate(pos)
win.blit(self.surface,pos)
class label(widget):
def __init__(self,text,size=30,
color=(0,0,0),font=_df):
self.surface = font.render(text,size,color)
class entry(widget):
def __init__(self,hint='',fontSize=30,font=_df,
width=None,height=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 or self.height == None:
if self.hint != '':
hintSize = self.font.size(self.hint,self.fontSize)
else:
hintSize = (150,self.font.size('X',self.fontSize)[1])
if self.height == None:
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:
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':
self.focus = False
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 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 _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 text in self.blacklist:
return
if self.whitelist != None:
if text not in self.whitelist:
return
if self.maxSymbols != None:
if len(self.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 self.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.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
else:
self.height = self.font.size('X',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)
try:
last = self.text.split('\n')[-1]
except:
last = self.text
x = 10
if self.font.size(last,self.fontSize)[0] >= self.surface.size[0]-20:
x = self.surface.size[0]-self.font.size(last,self.fontSize)[0]
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(self.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+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
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)
try:
last = self.text.split('\n')[-1]
except:
last = self.text
x = self.surface.size[0]/2-text.size[0]/2
if self.font.size(last,self.fontSize)[0] >= self.surface.size[0]-20:
x = self.surface.size[0]-self.font.size(last,self.fontSize)[0]
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 _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 text in self.blacklist:
return
if self.whitelist != None:
if text not in self.whitelist:
return
if self.maxSymbols != None:
if len(self.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 self.text
class keySelect(entry):
def __init__(self,keyBefore='',
fontSize=30,font=_df,
width=None,height=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.hint = ''
self.text = keyBefore
self.focus = False
self.tick = 0
self.wcl = False
self.startHint = self.hint
self.ws = False
if self.width == None or self.height == None:
if self.hint != '':
hintSize = self.font.size(self.hint,self.fontSize)
else:
hintSize = (150,self.font.size('X',self.fontSize)[1])
if self.height == None:
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:
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 = 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))
for i in _k.getPressed().items():
if i[1] and self.focus:
if i[0] in self.blacklist:
continue
if self.whitelist != None:
if i[0] not in self.whitelist:
continue
if self.maxSymbols != None:
if len(self.text) > self.maxSymbols:
continue
self.text = i[0]
break
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 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 draw(self, win, pos):
self._generate(pos)
win.blit(self.surface,pos)
def get(self):
return self.text
class image(widget):
def __init__(self, path):
self.surface = _l(path)
class loadingBar(widget):
def __init__(self,width,
height=50,
length=100,
bg=(70,70,70),
loadedColor=(50,200,50),
borderColor=(50,50,50),
borderWidth=5):
super()._args(locals())
self.loaded = 0
def step(self,count=1):
self.loaded += 1
if self.loaded > self.length:
self.loaded = self.length
def set(self, x):
self.loaded = x
if self.loaded > self.length:
self.loaded = self.length
def reset(self):
self.loaded = 0
def get(self):
return self.loaded
def draw(self, win, pos):
self.surface = _s((self.width,self.height))
self.surface.fill(self.borderColor)
self.surface.draw.rect(self.bg,_r(5,5,
self.surface.size[0]-10,
self.surface.size[1]-10))
self.surface.draw.rect(self.loadedColor,_r(self.borderWidth,self.borderWidth,
(self.surface.size[0]/self.length*self.loaded)-self.borderWidth*2,
self.surface.size[1]-self.borderWidth*2))
win.blit(self.surface, pos)
class slider(widget):
def __init__(self,width,
bg=(70,70,70),
fg=(200,200,200),
horizontal=True):
super()._args(locals())
self.s = False
self.x = 12.5
self._generate(None)
def _generate(self, pos):
if self.horizontal:
self.surface = _s((self.width,50))
self.surface.draw.line(self.bg,[12.5,25],[self.width-12.5,25],10)
self.surface.draw.circle(self.bg,[12.5,26],5)
self.surface.draw.circle(self.bg,[self.width-12.5,26],5)
self.surface.draw.circle(self.fg,[self.x,25],12.5)
else:
self.surface = _s((50,self.width))
self.surface.draw.line(self.bg,[25,12.5],[25,self.width-12.5],10)
self.surface.draw.circle(self.bg,[26,12.5],5)
self.surface.draw.circle(self.bg,[26,self.width-12.5],5)
self.surface.draw.circle(self.fg,[25,self.x],12.5)
if pos != None:
if _m.isPressed('left'):
if self.horizontal:
rect = _r(pos[0]+5,pos[1],
self.surface.size[0]-10,
self.surface.size[1])
if rect.contains(_m.getPosition()[0],
_m.getPosition()[1]) or self.s:
self.x = _m.getPosition()[0]-pos[0]
if self.x < 12.5: self.x = 12.5
if self.x > self.width-12.5: self.x = self.width-12.5
self.s = True
else:
rect = _r(pos[0],pos[1]+5,
self.surface.size[0],
self.surface.size[1]-10)
if rect.contains(_m.getPosition()[0],
_m.getPosition()[1]) or self.s:
self.x = _m.getPosition()[1]-pos[1]
if self.x < 12.5: self.x = 12.5
if self.x > self.width-12.5: self.x = self.width-12.5
self.s = True
else:
self.s = False
def get(self):
return int(self.x/(self.width-10)*101)
def set(self, x):
self.x = x/101*(self.width-10)
def draw(self, win, pos):
self._generate(pos)
win.blit(self.surface, pos)
class checkBox(widget):
def __init__(self,width=50,bg=(180,180,180),
fg=(50,180,50),afg=(70,200,70),
abg=(120,120,120),borderColor=(220,220,220),
borderWidth=5):
super()._args(locals())
self.cl0 = False
self.cl1 = False
self.nc0 = True
self.x = False
self._generate()
def set(self, x):
self.x = x
def get(self):
return self.x
def _generate(self, position=None):
self.surface = _s((self.width,self.width))
if position != None:
contains = self.surface.rect(position[0], position[1]).contains(
_m.getPosition()[0], _m.getPosition()[1])
cacm = contains and _m.isPressed('left')
else:
contains = False
cacm = False
if contains and not self.cl0:
_m.setCursor(_pg.SYSTEM_CURSOR_HAND)
self.cl0 = True
self.nc0 = True
elif not contains:
if self.nc0:
_m.setCursor(_pg.SYSTEM_CURSOR_ARROW)
self.nc0 = False
self.cl0 = False
if cacm and not self.cl1:
self.x=self.x==0
self.cl1 = True
elif not cacm:
self.cl1 = False
self.surface.fill(self.borderColor)
if cacm:
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.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)
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)
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 = {}
self._bg = bg
self._win = win
self._page = 0
def draw(self):
self._win.fill(self._bg)
for i in self._widgets[self._page]:
if i[0].power:
i[0].draw(self._win, i[1])
if i[0].destroyed:
self._widgets[self._page].remove(i)
def put(self, widget, pos, page=0):
if page not in self._widgets:
self._widgets.update({page:[]})
self._widgets[page].append([widget, pos])
def selectPage(self, page):
self._page = page
def getPage(self):
return self._page
def getWidgets(self, page=0):
return self._widgets[page]
def setWidgetPos(self,index,pos,page=0):
self._widgets[page][index] = [self._widgets[page][index][0], pos]

View file

@ -0,0 +1,21 @@
Metadata-Version: 2.1
Name: pygwin0
Version: 0.0.1
Summary: A library for creating Python applications.
Home-page: https://github.com/themixray/pygwin
Author: themixray
Author-email: simindeymo@gmail.com
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/themixray/pygwin/issues
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](https://github.com/themixray/pygwin/wiki)

View file

@ -0,0 +1,8 @@
LICENSE
README.md
pyproject.toml
setup.cfg
src/pygwin0.egg-info/PKG-INFO
src/pygwin0.egg-info/SOURCES.txt
src/pygwin0.egg-info/dependency_links.txt
src/pygwin0.egg-info/top_level.txt

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

3
tests/setup.bat Normal file
View file

@ -0,0 +1,3 @@
@echo off
python setup.py install
echo Complete!

6
tests/setup.py Normal file
View file

@ -0,0 +1,6 @@
from setuptools import setup
import requests
setup(name='pygwin',packages=['pygwin'],version='0.1.0',author='themixray',
description='A library for creating Python applications.',license='MIT',
install_requires=['cython','pywin32','pygame','inputs','pydub','wxPython'])