Example #1
0
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

from pywingui.windows import *
from pywingui.wtl import *

from pywingui import comctl
from pywingui import gdi

from pywingui.lib import tree
from pywingui.lib import form

from ctypes import *

blinkyIcon = Icon("blinky.ico")

comctl.InitCommonControls(comctl.ICC_TREEVIEW_CLASSES)


def as_pointer(obj):
    "Increment the refcount of obj, and return a pointer to it"
    ptr = pythonapi.Py_BuildValue("O", id(obj))
    assert ptr == id(obj)
    return ptr


def from_pointer(ptr):
    "Convert a pointer to a Python object, and decrement the refcount of the ptr"
    l = [None]
    # PyList_SetItem consumes a refcount of its 3. argument
    pythonDll.PyList_SetItem(id(l), 0, ptr)
    return l[0]
Example #2
0
captions = ['IP forwarding', 'Default initial TTL', 'Number of received datagrams', 'Number of received datagrams with header errors', 'Number of received datagrams with address errors', 'Number of datagrams forwarded', 'Number of received datagrams with an unknown protocol', 'Number of received datagrams discarded', 'Number of received datagrams delivered', 'Number of outgoing datagrams requested to transmit', 'Number of outgoing datagrams discarded for routing', 'Number of outgoing datagrams discarded', 'Number of outgoing datagrams with no route to destination discarded', 'Fragment reassembly timeout', 'Number of datagrams that required reassembly', 'Number of datagrams successfully reassembled', 'Number of datagrams that could not be reassembled', 'Number of datagrams fragmented successfully', 'Number of datagrams not fragmented and discarded', 'Number of fragments created', 'Number of interfaces', 'Number of IP addresses', 'Number of routes']

from pywingui.windows import *
from pywingui.wtl import *
from pywingui import comctl
from pywingui.lib import form
from pywingui.error import NO_ERROR

from pywingui.network.iphlpapi import GetIpStatistics

comctl.InitCommonControls(comctl.ICC_USEREX_CLASSES)

class Form(form.Form):
	_form_menu_ = [(MF_POPUP, '&File', [(MF_STRING, '&Exit', form.ID_EXIT)])]
	_window_title_ = 'GetIpStatistics Example'

	def __init__(self, *args, **kwargs):
		form.Form.__init__(self, *args, **kwargs)      
		#~ self.list_view.SetItemCount(len(captions))
		#~ self.list_view.SetRedraw(1)
		lvcolumn = comctl.LVCOLUMN(comctl.LVCF_TEXT|comctl.LVCF_WIDTH, 0, 500, 'item')
		self.list_view.InsertColumn(0, lvcolumn)
		lvcolumn = comctl.LVCOLUMN(comctl.LVCF_TEXT|comctl.LVCF_WIDTH, 0, 100, 'value')
		self.list_view.InsertColumn(1, lvcolumn)
		item_flags = comctl.LVIF_TEXT|comctl.LVIF_DI_SETITEM
		items = []
		for i in range(len(captions)):
			item = comctl.LVITEM(item_flags)
			item.iItem = i
			item.pszText = captions[i]
			self.list_view.InsertItem(item)
Example #3
0
## 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

from pywingui.windows import *
from pywingui.wtl import *

from pywingui import comctl
from pywingui import gdi
from pywingui.lib import form
from pywingui.lib import list
from pywingui.lib import coolbar
from pywingui.lib import trackbar

comctl.InitCommonControls(comctl.ICC_LISTVIEW_CLASSES | comctl.ICC_COOL_CLASSES
                          | comctl.ICC_USEREX_CLASSES | comctl.ICC_BAR_CLASSES)

iml = comctl.ImageList(32, 32, ILC_COLOR32 | ILC_MASK, 0, 32)
iml.AddIconsFromModule("shell32.dll", 32, 32, LR_LOADMAP3DCOLORS)
iml.SetBkColor(gdi.CLR_NONE)


class MyTrackBar(trackbar.TrackBar):
    def OnScroll(self, event):
        print "onscroll!"


class MyForm(form.Form):
    _window_icon_ = Icon("cow.ico")
    _window_icon_sm_ = _window_icon_
    _window_background_ = 0
Example #4
0
'GdiPlus Fern Fractal generator based on pyWinGUI, original was written on ActionScript by Jim Bumgardner 2008'

import math

from pywingui.wtl import *
from pywingui import gdi
from pywingui import gdiplusflat as gdiplus
from pywingui import comctl
from pywingui.lib import form, splitter, trackbar

comctl.InitCommonControls(comctl.ICC_COOL_CLASSES | comctl.ICC_BAR_CLASSES
                          | comctl.ICC_STANDARD_CLASSES)


class fern_canvas(Window):
    _window_style_ = WS_CHILD | WS_VISIBLE | WS_TABSTOP
    _window_background_ = gdi.GetStockObject(gdi.WHITE_BRUSH)
    _window_style_ex_ = WS_EX_CLIENTEDGE

    maxLevels = 6
    initBendAngle = 15
    initBranchAngle = 37
    trunkRatio = 0.1
    branchRatio = 0.4
    heightScale = 1.5
    redrawing = True

    def draw(self, graphics, px, py, a, rad, level):
        cx = int(px + math.cos(a) * rad * self.trunkRatio)
        cy = int(py + math.sin(a) * rad * self.trunkRatio)
        status, pen = gdiplus.GdipCreatePen1(
Example #5
0
from pywingui.windows import *
from pywingui.wtl import *
from pywingui import comctl
from pywingui.lib import form, trackbar

comctl.InitCommonControls(comctl.ICC_USEREX_CLASSES
                          | comctl.ICC_STANDARD_CLASSES)


class Form(form.Form):
    _form_menu_ = [(MF_POPUP, '&File', [(MF_STRING, '&Exit', form.ID_EXIT)])]
    _window_title_ = 'pyWinGUI Track Bar Example'
    CAPTION_FMT = 'Track Bar value: %d'

    class myTrackBar(trackbar.TrackBar):
        def OnScroll(self, event):
            self.parent.caption.SetText(self.parent.CAPTION_FMT %
                                        self.GetPos())

    def __init__(self, *args, **kwargs):
        form.Form.__init__(self, *args, **kwargs)
        position = 50
        self.caption = comctl.StaticText(self.CAPTION_FMT % position,
                                         rcPos=RECT(0, 0, 700, 20),
                                         parent=self)
        self.track_bar = self.myTrackBar(rcPos=RECT(0, 20, 700, 50),
                                         parent=self)
        self.track_bar.SetRange(0, 100)
        self.track_bar.SetPos(position)

    def OnCreate(self, event):