Add files via upload
This commit is contained in:
parent
abef24e1aa
commit
815a7bea90
26 changed files with 1380 additions and 91 deletions
|
@ -1,35 +1,35 @@
|
|||
try:
|
||||
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 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)
|
||||
except ModuleNotFoundError as e:
|
||||
import pip,os,sys
|
||||
if 'imofpgw' in sys.argv:
|
||||
os.system('cls' if os.name in ('nt', 'dos') else 'clear')
|
||||
raise e
|
||||
def install(package):
|
||||
if hasattr(pip,'main'):pip.main(['install',package])
|
||||
else:pip._internal.main(['install',package])
|
||||
os.system('cls' if os.name in ('nt', 'dos') else 'clear')
|
||||
modules = ['datetime',
|
||||
'tempfile',
|
||||
'pywin32',
|
||||
'pickle',
|
||||
'pygame',
|
||||
'inputs',
|
||||
'pydub',
|
||||
'ctypes']
|
||||
for i in modules:
|
||||
install(i)
|
||||
os.execv(sys.executable, ['python']+sys.argv+['imofpgw'])
|
||||
# try:
|
||||
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 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)
|
||||
# except ModuleNotFoundError as e:
|
||||
# import pip,os,sys
|
||||
# if 'imofpgw' in sys.argv:
|
||||
# os.system('cls' if os.name in ('nt', 'dos') else 'clear')
|
||||
# raise e
|
||||
# def install(package):
|
||||
# if hasattr(pip,'main'):pip.main(['install',package])
|
||||
# else:pip._internal.main(['install',package])
|
||||
# os.system('cls' if os.name in ('nt', 'dos') else 'clear')
|
||||
# modules = ['datetime',
|
||||
# 'tempfile',
|
||||
# 'pywin32',
|
||||
# 'pickle',
|
||||
# 'pygame',
|
||||
# 'inputs',
|
||||
# 'pydub',
|
||||
# 'ctypes']
|
||||
# for i in modules:
|
||||
# install(i)
|
||||
# os.execv(sys.executable, ['python']+sys.argv+['imofpgw'])
|
||||
|
|
1
pygwin/_icon.py
Normal file
1
pygwin/_icon.py
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,11 +1,16 @@
|
|||
from pygwin.surface import surface as _surface
|
||||
from datetime import datetime as _dt
|
||||
from pygwin._pg import pg as _pg
|
||||
from pygwin.image import save as _s
|
||||
from pygwin._pg import pg as _pg
|
||||
import pygwin._icon as _icon
|
||||
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):
|
||||
|
@ -88,53 +93,45 @@ class win(_surface):
|
|||
def visible(self):
|
||||
return _w32g.IsWindowVisible(self._win)
|
||||
|
||||
|
||||
def create(title=None, size=(0,0), icon=None):
|
||||
def create(title=None, size=(0,0), icon=None, resizable=False, noframe=False):
|
||||
screen = _pg.display.set_mode(size)
|
||||
if title != None: _pg.display.set_caption(title)
|
||||
if icon != None: _pg.display.set_icon(_pg.image.load(icon))
|
||||
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))
|
||||
else:
|
||||
surf = _img.fromBytes(_icon.iconbytes)
|
||||
try:
|
||||
orig = surf._surface_orig
|
||||
except:
|
||||
orig = surf._orig
|
||||
_pg.display.set_icon(orig)
|
||||
return win()
|
||||
|
||||
def ramLimit(bytes):
|
||||
def create_job(job_name='', breakaway='silent'):
|
||||
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)
|
||||
return hjob
|
||||
def assign_job(hjob):
|
||||
global g_hjob
|
||||
hprocess = _w32a.GetCurrentProcess()
|
||||
try:
|
||||
_w32j.AssignProcessToJobObject(hjob, hprocess)
|
||||
g_hjob = hjob
|
||||
except _w32j.error as e:
|
||||
if (e.winerror != winerror.ERROR_ACCESS_DENIED or
|
||||
sys.getwindowsversion() >= (6, 2) or
|
||||
not _w32j.IsProcessInJob(hprocess, None)):
|
||||
raise
|
||||
warnings.warn('The process is already in a job. Nested jobs are not '
|
||||
'supported prior to Windows 8.')
|
||||
def limit_memory(memory_limit):
|
||||
if g_hjob is None:
|
||||
return
|
||||
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)
|
||||
assign_job(create_job())
|
||||
limit_memory(bytes)
|
||||
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 or \
|
||||
sys.getwindowsversion() >= (6, 2) or \
|
||||
not _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()
|
||||
|
|
|
@ -16,6 +16,7 @@ class widget:
|
|||
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):
|
||||
|
@ -31,6 +32,7 @@ class widget:
|
|||
for i in parameters.items():
|
||||
if i[0] in list(self.__dict__.keys()):
|
||||
exec(f'self.{i[0]} = parameters["{i[0]}"]')
|
||||
self.__init__(**self._args)
|
||||
class button(widget):
|
||||
def __init__(self,text,
|
||||
func=lambda:None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue