Add files via upload

This commit is contained in:
themixray 2021-11-04 18:48:57 +03:00 committed by GitHub
parent ebe835c23b
commit 58a02f935b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 4 deletions

View file

@ -1,6 +1,7 @@
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

View file

@ -1,8 +1,11 @@
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
import win32job as _w32j
import win32api as _w32a
import win32con as _w32c
import win32gui as _w32g
class win(_surface):
def __init__(self):
@ -33,7 +36,7 @@ class win(_surface):
def fget(self):
return _pg.display.get_window_size()
def fset(self, value):
if type(value) != tuple or type(value) != list:
if type(value) in [list,tuple]:
return
_pg.display.set_mode(value)
def fdel(self):
@ -44,6 +47,31 @@ class win(_surface):
_pg.display.toogle_fullscreen()
def close(self):
_pg.display.quit()
_w32g.PostMessage(self.hwnd, _w32c.WM_CLOSE, 0, 0)
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:
@ -56,6 +84,10 @@ class win(_surface):
@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):
screen = _pg.display.set_mode(size)

62
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

View file

@ -254,7 +254,7 @@ class loadingBar(widget):
(self.surface.size[0]/self.length*self.loaded)-self.borderWidth*2,
self.surface.size[1]-self.borderWidth*2))
win.blit(self.surface, pos)
class scrollBar(widget):
class slider(widget):
def __init__(self,width,
bg=(70,70,70),
fg=(50,200,50),
@ -268,13 +268,13 @@ class scrollBar(widget):
self.surface.draw.line(self.bg,[5,25],[self.width-5,25],10)
self.surface.draw.circle(self.bg,[5,26],5)
self.surface.draw.circle(self.bg,[self.width-5,26],5)
self.surface.draw.line(self.fg,[self.x+5,11],[self.x+5,39],6)
self.surface.draw.circle(self.fg,[self.x+5,25],25)
else:
self.surface = _s((50,self.width))
self.surface.draw.line(self.bg,[25,5],[25,self.width-5],10)
self.surface.draw.circle(self.bg,[26,5],5)
self.surface.draw.circle(self.bg,[26,self.width-5],5)
self.surface.draw.line(self.fg,[11,self.x+5],[39,self.x+5],6)
self.surface.draw.circle(self.fg,[25,self.x+5],25)
if pos != None:
if _m.isPressed('left'):
if self.horizontal: