Пример #1
0
    def OnNcPaint(self, msg):
        self.EraseNonClient()
        dc = self.GetWindowDC()
        ctl = win32api.GetSysColor(win32con.COLOR_BTNHIGHLIGHT)
        cbr = win32api.GetSysColor(win32con.COLOR_BTNSHADOW)
        dc.Draw3dRect(self.rectBorder, ctl, cbr)

        self.DrawGripper(dc)

        rect = self.GetClientRect()
        self.InvalidateRect(rect, 1)
        return 0
Пример #2
0
 def OnPrepareDC(self, dc, printinfo):
     # Set up the DC for forthcoming OnDraw call
     self.SetScrollSizes(win32con.MM_TEXT, (100, 100))
     dc.SetTextColor(win32api.RGB(0, 0, 255))
     dc.SetBkColor(win32api.GetSysColor(win32con.COLOR_WINDOW))
     dc.SelectObject(self.font)
     dc.SetTextAlign(win32con.TA_CENTER | win32con.TA_BASELINE)
Пример #3
0
    def _ReformatStyle(self, style):
        assert style.stylenum is not None, "Unregistered style."
        #print "Reformat style", style.name, style.stylenum
        scintilla = self.scintilla
        stylenum = style.stylenum
        # Now we have the style number, indirect for the actual style.
        if style.aliased is not None:
            style = self.styles[style.aliased]
        f = style.format
        if style.IsBasedOnDefault():
            baseFormat = self.GetDefaultFormat()
        else:
            baseFormat = f
        scintilla.SCIStyleSetFore(stylenum, f[4])
        scintilla.SCIStyleSetFont(stylenum, baseFormat[7], baseFormat[5])
        if f[1] & 1: scintilla.SCIStyleSetBold(stylenum, 1)
        else: scintilla.SCIStyleSetBold(stylenum, 0)
        if f[1] & 2: scintilla.SCIStyleSetItalic(stylenum, 1)
        else: scintilla.SCIStyleSetItalic(stylenum, 0)
        scintilla.SCIStyleSetSize(stylenum, int(baseFormat[2] / 20))
        scintilla.SCIStyleSetEOLFilled(stylenum,
                                       1)  # Only needed for unclosed strings.

        ## Default style background to whitespace background if set,
        ##	otherwise use system window color
        bg = style.background
        if bg == CLR_INVALID:
            bg = self.styles[STYLE_DEFAULT].background
        if bg == CLR_INVALID:
            bg = win32api.GetSysColor(win32con.COLOR_WINDOW)
        scintilla.SCIStyleSetBack(stylenum, bg)
Пример #4
0
	def _LoadBackground( self ):
		#load default background
		bg = int( self.LoadPreference( "Default Background", -1 ) )
		if bg != -1:
			self.default_background = bg
		if self.default_background is None:
			self.default_background = win32api.GetSysColor(win32con.COLOR_WINDOW)
Пример #5
0
    def __init__(self, obj=None):
        if obj is None:
            obj = win32ui.CreateControlBar()
        window.Wnd.__init__(self, obj)
        self.dialog = None
        self.nDockBarID = 0
        self.sizeMin = 32, 32
        self.sizeHorz = 200, 200
        self.sizeVert = 200, 200
        self.sizeFloat = 200, 200
        self.bTracking = 0
        self.bInRecalcNC = 0
        self.cxEdge = 6
        self.cxBorder = 3
        self.cxGripper = 20
        self.brushBkgd = win32ui.CreateBrush()
        self.brushBkgd.CreateSolidBrush(
            win32api.GetSysColor(win32con.COLOR_BTNFACE))

        # Support for diagonal resizing
        self.cyBorder = 3
        self.cCaptionSize = win32api.GetSystemMetrics(win32con.SM_CYSMCAPTION)
        self.cMinWidth = win32api.GetSystemMetrics(win32con.SM_CXMIN)
        self.cMinHeight = win32api.GetSystemMetrics(win32con.SM_CYMIN)
        self.rectUndock = (0, 0, 0, 0)
Пример #6
0
def __add_color(name, sysindex):
    rgb = None
    # make sure it doesn't crash if there is a problem
    try:
        color = win32api.GetSysColor(sysindex)
        if color != None and color >= 0:
            rgb = sdk.GetRGBValues(color)
    except:
        print 'systemcolor: error to get color ', name

    if type(rgb) is type(()):
        colors[name] = rgb
Пример #7
0
    def _ReformatStyle(self, style):
        ## Selection (background only for now)
        ## Passing False for WPARAM to SCI_SETSELBACK is documented as resetting to scintilla default,
        ## but does not work - selection background is not visible at all.
        ## Default value in SPECIAL_STYLES taken from scintilla source.
        if style.name == STYLE_SELECTION:
            clr = style.background
            self.scintilla.SendScintilla(scintillacon.SCI_SETSELBACK, True,
                                         clr)

            ## Can't change font for selection, but could set color
            ## However, the font color dropbox has no option for default, and thus would
            ## always override syntax coloring
            ## clr = style.format[4]
            ## self.scintilla.SendScintilla(scintillacon.SCI_SETSELFORE, clr != CLR_INVALID, clr)
            return

        assert style.stylenum is not None, "Unregistered style."
        # print "Reformat style", style.name, style.stylenum
        scintilla = self.scintilla
        stylenum = style.stylenum
        # Now we have the style number, indirect for the actual style.
        if style.aliased is not None:
            style = self.styles[style.aliased]
        f = style.format
        if style.IsBasedOnDefault():
            baseFormat = self.GetDefaultFormat()
        else:
            baseFormat = f
        scintilla.SCIStyleSetFore(stylenum, f[4])
        scintilla.SCIStyleSetFont(stylenum, baseFormat[7], baseFormat[5])
        if f[1] & 1:
            scintilla.SCIStyleSetBold(stylenum, 1)
        else:
            scintilla.SCIStyleSetBold(stylenum, 0)
        if f[1] & 2:
            scintilla.SCIStyleSetItalic(stylenum, 1)
        else:
            scintilla.SCIStyleSetItalic(stylenum, 0)
        scintilla.SCIStyleSetSize(stylenum, int(baseFormat[2] / 20))
        scintilla.SCIStyleSetEOLFilled(stylenum,
                                       1)  # Only needed for unclosed strings.

        ## Default style background to whitespace background if set,
        ##	otherwise use system window color
        bg = style.background
        if bg == CLR_INVALID:
            bg = self.styles[STYLE_DEFAULT].background
        if bg == CLR_INVALID:
            bg = win32api.GetSysColor(win32con.COLOR_WINDOW)
        scintilla.SCIStyleSetBack(stylenum, bg)
Пример #8
0
#--------------------------------------------------------------------
#
#   PyGUI - Win32 - Utilities
#
#--------------------------------------------------------------------

import win32con as wc, win32ui as ui, win32gui as gui, win32api as api
from win32api import HIWORD, LOWORD
from GUI import application
from GUI.Exceptions import Cancel, InternalError

win_dlog_class = "#32770"
win_color3dhilight = api.GetSysColor(wc.COLOR_3DHILIGHT)
win_color3dlight = api.GetSysColor(wc.COLOR_3DLIGHT)
win_color3dface = api.GetSysColor(wc.COLOR_3DFACE)
win_color3dshadow = api.GetSysColor(wc.COLOR_3DSHADOW)
win_menubar_height = api.GetSystemMetrics(wc.SM_CYMENU)
win_bg_color = api.GetSysColor(wc.COLOR_3DFACE)
win_screen_width = api.GetSystemMetrics(wc.SM_CXFULLSCREEN)
win_screen_height = api.GetSystemMetrics(wc.SM_CYFULLSCREEN)
win_screen_rect = (0, 0, win_screen_width, win_screen_height)

#win_bg_brush = ui.CreateBrush(wc.BS_SOLID, win_color3dface, 0)
#win_bg_hbrush = win_bg_brush.GetSafeHandle()

#  An empty brush for not painting anything with
win_null_brush = ui.CreateBrush(wc.BS_NULL, 0, 0)
win_null_hbrush = win_null_brush.GetSafeHandle()

#  All components hook the following messages
    for key, (hwnd, title) in enumerate(windows):
        print((hwnd, title))
        try:
            win32gui.DrawFocusRect(
                hwnd, (200 + key, 200 + key, 600 + key, 600 + key))
        except:
            pass
        ask = input('stop? ')
        if ask == 'yes':
            break
'''
todo:
    write script which change colors of elements, depend on time of the day, weather, sun...
    
'''
'''
https://docs.microsoft.com/pl-pl/windows/win32/api/winuser/nf-winuser-getsyscolor

sys colors:
win32api.GetSysColor(4)         # returns the color of element nr 4



Parameters
nIndex

Type: int

The display element whose color is to be retrieved. This parameter can be one of the following values.

Value	Meaning
Пример #10
0
     scintillacon.SCE_P_DEFNAME),
    (STYLE_OPERATOR, (0, 0, 200, 0, 0x000000), CLR_INVALID,
     scintillacon.SCE_P_OPERATOR),
    (STYLE_IDENTIFIER, (0, 0, 200, 0, 0x000000), CLR_INVALID,
     scintillacon.SCE_P_IDENTIFIER),
]

# These styles _always_ have this specific style number, regardless of
# internal or external formatter.
SPECIAL_STYLES = [
    (STYLE_BRACE, (0, 0, 200, 0, 0x000000), 0xffff80,
     scintillacon.STYLE_BRACELIGHT),
    (STYLE_BRACEBAD, (0, 0, 200, 0, 0x000000), 0x8ea5f2,
     scintillacon.STYLE_BRACEBAD),
    (STYLE_LINENUMBER, (0, 0, 200, 0, 0x000000),
     win32api.GetSysColor(win32con.COLOR_3DFACE),
     scintillacon.STYLE_LINENUMBER),
    (STYLE_INDENTGUIDE, (0, 0, 200, 0, 0x000000), CLR_INVALID,
     scintillacon.STYLE_INDENTGUIDE),
    ## Not actually a style; requires special handling to send appropriate messages to scintilla
    (STYLE_SELECTION, (0, 0, 200, 0, CLR_INVALID),
     win32api.RGB(0xc0, 0xc0, 0xc0), 999999),
]

PythonSampleCode = """\
# Some Python
class Sample(Super):
  def Fn(self):
\tself.v = 1024
dest = 'dest.html'
x = func(a + 1)|)
Пример #11
0
print(api.GetComputerName())
print(api.GetConsoleTitle())
print(api.GetCommandLine())
print(api.GetCursorPos())
print(api.GetDomainName())
print(api.GetEnvironmentVariable('path'))
print(api.GetFileAttributes('.'))
print(api.GetFileVersionInfo('C:\\windows\\system32\\cmd.exe', "\\"))
print(api.GetFullPathName('.'))
print(api.GetLocalTime())
print(api.GetLogicalDriveStrings().replace('\x00', ' '))
print(api.GetLogicalDrives())
print(api.GetLongPathName('C:'))
print(api.GetModuleFileName(0))
print(api.GetNativeSystemInfo())
print(hex(api.GetSysColor(con.COLOR_WINDOW)))
print(api.GetSystemDirectory())
print(api.GetSystemInfo())
print(api.GetSystemMetrics(con.SM_CXSCREEN))
print(api.GetSystemTime())
print(api.GetTickCount())
# print(api.GetTimeZoneInformation())
print(api.GetUserDefaultLangID())
print(api.GetUserName())
print(api.GetVersion())
print(api.GetVolumeInformation('C:'))
print(api.GetWindowsDirectory())
print(api.GlobalMemoryStatus())
print(api.MessageBeep())
print(api.MessageBox(0, 'hello', 'world', con.MB_OK))
size = api.RegQueryInfoKey(con.HKEY_LOCAL_MACHINE)
Пример #12
0
#   PyGUI - Color utilities - Win32
#
#--------------------------------------------------------------------

import win32con as wc, win32api as api
from GUI import Color


def rgb(red, green, blue, alpha=1.0, image=False, im=''):
    color = Color()
    color.image = image
    if image:
        color.image = im._win_image
    else:
        color._red = red
        color._green = green
        color._blue = blue
        color._alpha = alpha
        color._win_color = (int(red * 255) | int(green * 255) << 8
                            | int(blue * 255) << 16)
        color._win_argb = (int(blue * 255) | int(green * 255) << 8
                           | int(red * 255) << 16 | int(alpha * 255) << 24)
    return color


selection_forecolor = Color._from_win_color(
    api.GetSysColor(wc.COLOR_HIGHLIGHTTEXT))

selection_backcolor = Color._from_win_color(api.GetSysColor(
    wc.COLOR_HIGHLIGHT))
Пример #13
0
#
#   PyGUI - Color utilities - Win32
#
#--------------------------------------------------------------------

import win32con as wc, win32api as api
from GUI import Color

def rgb(red, green, blue, alpha = 1.0):
    color = Color()
    color._red = red
    color._green = green
    color._blue = blue
    color._alpha = alpha
    color._win_color = (
        int(red * 255) |
        int(green * 255) << 8 |
        int(blue * 255) << 16)
    color._win_argb = (
        int(blue * 255) |
        int(green * 255) << 8 |
        int(red * 255) << 16 |
        int(alpha * 255) << 24)
    return color

selection_forecolor = Color._from_win_color(
    api.GetSysColor(wc.COLOR_HIGHLIGHTTEXT))

selection_backcolor = Color._from_win_color(
    api.GetSysColor(wc.COLOR_HIGHLIGHT))
Пример #14
0
# DockingBar.py

# Ported directly (comments and all) from the samples at www.codeguru.com

# WARNING: Use at your own risk, as this interface is highly likely to change.
# Currently we support only one child per DockingBar.  Later we need to add
# support for multiple children.

import struct

import win32api
import win32con
import win32ui
from pywin.mfc import afxres, window

clrBtnHilight = win32api.GetSysColor(win32con.COLOR_BTNHILIGHT)
clrBtnShadow = win32api.GetSysColor(win32con.COLOR_BTNSHADOW)


def CenterPoint(rect):
    width = rect[2] - rect[0]
    height = rect[3] - rect[1]
    return rect[0] + width // 2, rect[1] + height // 2


def OffsetRect(rect, point):
    (x, y) = point
    return rect[0] + x, rect[1] + y, rect[2] + x, rect[3] + y


def DeflateRect(rect, point):
Пример #15
0
		(STYLE_TQSSTRING,    STYLE_STRING,             CLR_INVALID,     scintillacon.SCE_P_TRIPLE ),
		(STYLE_TQDSTRING,    STYLE_STRING,             CLR_INVALID,     scintillacon.SCE_P_TRIPLEDOUBLE),
		(STYLE_STRINGEOL,    (0, 0, 200, 0, 0x000000), 0x008080, scintillacon.SCE_P_STRINGEOL),
		(STYLE_KEYWORD,      (0, 1, 200, 0, 0x800000), CLR_INVALID,     scintillacon.SCE_P_WORD),
		(STYLE_CLASS,        (0, 1, 200, 0, 0xFF0000), CLR_INVALID,     scintillacon.SCE_P_CLASSNAME ),
		(STYLE_METHOD,       (0, 1, 200, 0, 0x808000), CLR_INVALID,     scintillacon.SCE_P_DEFNAME),
		(STYLE_OPERATOR,     (0, 0, 200, 0, 0x000000), CLR_INVALID,     scintillacon.SCE_P_OPERATOR),
		(STYLE_IDENTIFIER,   (0, 0, 200, 0, 0x000000), CLR_INVALID,     scintillacon.SCE_P_IDENTIFIER ),
]

# These styles _always_ have this specific style number, regardless of
# internal or external formatter.
SPECIAL_STYLES = [
		(STYLE_BRACE,        (0, 0, 200, 0, 0x000000), 0xffff80, scintillacon.STYLE_BRACELIGHT),
		(STYLE_BRACEBAD,     (0, 0, 200, 0, 0x000000), 0x8ea5f2, scintillacon.STYLE_BRACEBAD),
		(STYLE_LINENUMBER,   (0, 0, 200, 0, 0x000000), win32api.GetSysColor(win32con.COLOR_3DFACE), scintillacon.STYLE_LINENUMBER),
		(STYLE_INDENTGUIDE,  (0, 0, 200, 0, 0x000000), CLR_INVALID, scintillacon.STYLE_INDENTGUIDE),
		## Not actually a style; requires special handling to send appropriate messages to scintilla
		(STYLE_SELECTION,    (0, 0, 200, 0, CLR_INVALID), win32api.RGB(0xc0, 0xc0, 0xc0), 999999),
]

PythonSampleCode = """\
# Some Python
class Sample(Super):
  def Fn(self):
\tself.v = 1024
dest = 'dest.html'
x = func(a + 1)|)
s = "I forget...
## A large
## comment block"""