Fix imports, apply black
This commit is contained in:
parent
ab8644b9ec
commit
d038fcd217
@ -4,48 +4,56 @@
|
||||
|
||||
|
||||
import sys
|
||||
import xforms
|
||||
import forms
|
||||
import objects
|
||||
import bitmaps
|
||||
import pixmaps
|
||||
import box
|
||||
import browser
|
||||
import button
|
||||
import choice
|
||||
import clock
|
||||
import counter
|
||||
import dial
|
||||
import frame
|
||||
import input
|
||||
import menu
|
||||
import positioner
|
||||
import slider
|
||||
import timer
|
||||
from . import (
|
||||
xforms,
|
||||
forms,
|
||||
objects,
|
||||
bitmaps,
|
||||
pixmaps,
|
||||
box,
|
||||
browser,
|
||||
button,
|
||||
choice,
|
||||
clock,
|
||||
counter,
|
||||
dial,
|
||||
frame,
|
||||
input,
|
||||
menu,
|
||||
positioner,
|
||||
slider,
|
||||
timer,
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# These are function needed to run the XForms library
|
||||
# Needs a LOT of work
|
||||
|
||||
|
||||
def xfinit(appname, appclass, argv0):
|
||||
xforms.init(appname, appclass, argv0)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the synthetic event-loop to use under python:
|
||||
|
||||
_objects = {}
|
||||
|
||||
|
||||
def runforms():
|
||||
while 1:
|
||||
ob = _objects[str(xforms.do_forms())]
|
||||
ob.cb(ob.args)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the default callback function:
|
||||
|
||||
|
||||
def _nocb(args):
|
||||
print("This object has no Callback!")
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the Form class
|
||||
|
||||
@ -67,40 +75,55 @@ class Form:
|
||||
self.objs = () # A place to store the obj list. Useful?
|
||||
|
||||
def Show(self):
|
||||
self.winid=forms.show (self.id,self.__placement,self.__decoration,self.title)
|
||||
self.winid = forms.show(
|
||||
self.id, self.__placement, self.__decoration, self.title
|
||||
)
|
||||
|
||||
def Hide(self):
|
||||
forms.hide(self.id)
|
||||
|
||||
def Freeze(self):
|
||||
forms.freeze(self.id)
|
||||
|
||||
def Unfreeze(self):
|
||||
forms.unfreeze(self.id)
|
||||
|
||||
def Activate(self):
|
||||
forms.activate(self.id)
|
||||
|
||||
def Deactivate(self):
|
||||
forms.deactivate(self.id)
|
||||
|
||||
def Scale(self, x, y):
|
||||
forms.scale(self.id, x, y)
|
||||
|
||||
def Redraw(self):
|
||||
forms.redraw(self.id)
|
||||
|
||||
def Add(self, object):
|
||||
forms.add_object(self.id, object.id)
|
||||
object.parent = self
|
||||
|
||||
def Setminsize(self, x, y):
|
||||
forms.set_minsize(self.id, x, y)
|
||||
self.__minx = x # The __ is needed to avoid endless looping
|
||||
self.__miny = y # on min[xy], which are non-gettable from XForms
|
||||
|
||||
def Setmaxsize(self, x, y):
|
||||
forms.set_maxsize(self.id, x, y)
|
||||
self.__maxx = x
|
||||
self.__maxy = y
|
||||
|
||||
def Settitle(self, title):
|
||||
forms.set_title(self.id, title)
|
||||
self.__title = title
|
||||
|
||||
def Gettitle(self):
|
||||
if self.visible:
|
||||
return forms.get_title(self.id)
|
||||
else:
|
||||
return self.__title
|
||||
|
||||
def Setcolor(c1, c2):
|
||||
self.__box.Setcolor(c1, c2)
|
||||
|
||||
@ -151,7 +174,6 @@ class Form:
|
||||
else:
|
||||
self.__dict__[name] = value
|
||||
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name == "x":
|
||||
(tx, ty, tw, th) = forms.get_geometry(self.id)
|
||||
@ -174,25 +196,39 @@ class Form:
|
||||
elif name == "maxy":
|
||||
return self.__maxy
|
||||
elif name == "vmode":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return vmode
|
||||
elif name == "active":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return active
|
||||
elif name == "dblbuffer":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return dblbuffer
|
||||
elif name == "frozen":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return frozen
|
||||
elif name == "visible":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return visible
|
||||
elif name == "border":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return border
|
||||
elif name == "other":
|
||||
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
|
||||
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
|
||||
self.id
|
||||
)
|
||||
return other
|
||||
elif name == "title":
|
||||
return self.Gettitle()
|
||||
@ -200,8 +236,11 @@ class Form:
|
||||
return self.__box.c1
|
||||
elif name == "c2":
|
||||
return self.__box.c2
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
|
||||
# I'm not sure if this is a nice thing to do
|
||||
# forms.free (self.id)
|
||||
|
||||
@ -209,32 +248,43 @@ class Form:
|
||||
###############################################################################
|
||||
# This is the XFObject class, for generic XForms objects
|
||||
|
||||
|
||||
class XFObject:
|
||||
def __init__(self):
|
||||
self.id = 0
|
||||
self.__c1 = 11
|
||||
self.__c2 = 15
|
||||
|
||||
def Setgravity(self, a, b):
|
||||
objects.set_gravity(self.id, a, b)
|
||||
|
||||
def Redraw(self):
|
||||
objects.redraw(self.id)
|
||||
|
||||
def Scale(self, x, y):
|
||||
objects.scale(self.id, x, y)
|
||||
|
||||
def Show(self):
|
||||
objects.show(self.id)
|
||||
self.Setcolor(self.__c1, self.__c2)
|
||||
|
||||
def Hide(self):
|
||||
objects.hide(self.id)
|
||||
|
||||
def Delete(self):
|
||||
objects.delete(self.id)
|
||||
|
||||
def Setcolor(self, c1, c2):
|
||||
self.__c1 = c1
|
||||
self.__c2 = c2
|
||||
objects.set_color(self.id, c1, c2)
|
||||
|
||||
def Activate(self):
|
||||
objects.activate(self.id)
|
||||
|
||||
def Deactivate(self):
|
||||
objects.deactivate(self.id)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name == "boxtype":
|
||||
objects.set_boxtype(self.id, value)
|
||||
@ -274,6 +324,7 @@ class XFObject:
|
||||
self.Setcolor(self.__c1, value)
|
||||
else:
|
||||
self.__dict__[name] = value
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name == "c1":
|
||||
return self.__c1
|
||||
@ -288,12 +339,15 @@ class XFObject:
|
||||
###############################################################################
|
||||
# The Bitmap Class
|
||||
|
||||
|
||||
class Bitmap(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=100, h=100, l="Bitmap"):
|
||||
XFObject.__init__(self)
|
||||
self.id = bitmaps.create(t, x, y, w, h, l)
|
||||
|
||||
def Load(self, file):
|
||||
bitmaps.set_file(self.id, file)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name == "background":
|
||||
objects.set_color(self.id, value, 0)
|
||||
@ -306,12 +360,15 @@ class Bitmap(XFObject):
|
||||
###############################################################################
|
||||
# The Pixmap Class
|
||||
|
||||
|
||||
class Pixmap(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=100, h=100, l="Pixmap"):
|
||||
XFObject.__init__(self)
|
||||
self.id = pixmaps.create(t, x, y, w, h, l)
|
||||
|
||||
def Load(self, file):
|
||||
pixmaps.set_file(self.id, file)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name == "background":
|
||||
objects.set_color(self.id, value, 0)
|
||||
@ -324,16 +381,20 @@ class Pixmap(XFObject):
|
||||
###############################################################################
|
||||
# The Box Class
|
||||
|
||||
|
||||
class Box(XFObject):
|
||||
def __init__(self, t=6, x=10, y=10, w=90, h=90, l="Box"):
|
||||
XFObject.__init__(self)
|
||||
self.id = box.create(t, x, y, w, h, l)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# The Browser class
|
||||
#
|
||||
# I want the Browser class to act just like what it is: a list
|
||||
# only with a "few" more methods and stuff
|
||||
|
||||
|
||||
class Browser(XFObject):
|
||||
def __init__(self, t=1, x=10, y=10, w=90, h=120, l="Browser"):
|
||||
XFObject.__init__(self)
|
||||
@ -341,46 +402,67 @@ class Browser (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Add(self, line):
|
||||
browser.add_line(self.id, line)
|
||||
|
||||
def Addto(self, line):
|
||||
browser.addto(self.id, line)
|
||||
|
||||
def Insert(self, n, line):
|
||||
browser.insert_line(self.id, n, line)
|
||||
|
||||
def Delete(self, n):
|
||||
browser.delete_line(self.id, n)
|
||||
|
||||
def Replace(self, n, line):
|
||||
browser.replace_line(self.id, n, line)
|
||||
|
||||
def Getline(self, n):
|
||||
return browser.get_line(self.id, n)
|
||||
|
||||
def Load(self, path):
|
||||
return browser.load(self.id, path)
|
||||
|
||||
def Select(self, n):
|
||||
browser.select_line(self.id, n)
|
||||
|
||||
def Deselect(self, n):
|
||||
browser.deselect_line(self.id, n)
|
||||
|
||||
def Deselectall(self):
|
||||
browser.deselect(self.id)
|
||||
|
||||
def Isselected(self, n):
|
||||
return browser.isselected_line(self.id, n)
|
||||
|
||||
def Gettopline(self):
|
||||
return browser.get_topline(self.id)
|
||||
|
||||
def Get(self):
|
||||
return browser.get(self.id)
|
||||
|
||||
def Getmaxline(self):
|
||||
return browser.get_maxline(self.id)
|
||||
|
||||
def Screenlines(self):
|
||||
return browser.get_screenlines(self.id)
|
||||
|
||||
def Settopline(self, n):
|
||||
browser.set_topline(self.id, n)
|
||||
|
||||
def Setfontsize(self, n):
|
||||
browser.set_fontsize(self.id, n)
|
||||
|
||||
def Setfontstyle(self, n):
|
||||
browser.set_fontstyle(self.id, n)
|
||||
|
||||
def Setspecialkey(self, c):
|
||||
browser.set_specialkey(self.id, c)
|
||||
|
||||
def Setleftslider(self, l):
|
||||
browser.set_leftslider(self.id, l)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name == "leftslider":
|
||||
self.Setleftslider(value)
|
||||
@ -396,10 +478,10 @@ class Browser (XFObject):
|
||||
XFObject.__setattr__(self, name, value)
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Button class.
|
||||
|
||||
|
||||
class Button(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Button"):
|
||||
XFObject.__init__(self)
|
||||
@ -407,6 +489,7 @@ class Button(XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def __call__(self, v=-1):
|
||||
# I think this is nice: if you have a button called b,
|
||||
# b() returns the button's value
|
||||
@ -432,9 +515,11 @@ class Button(XFObject):
|
||||
else:
|
||||
return XFObject.__getattr__(self, name)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Roundbutton class
|
||||
|
||||
|
||||
class Roundbutton(Button):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Roundbutton"):
|
||||
XFObject.__init__(self)
|
||||
@ -442,9 +527,12 @@ class Roundbutton (Button):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Lightbutton class
|
||||
|
||||
|
||||
class Lightbutton(Button):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Lightbutton"):
|
||||
XFObject.__init__(self)
|
||||
@ -452,9 +540,12 @@ class Lightbutton (Button):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Checkbutton class
|
||||
|
||||
|
||||
class Checkbutton(Button):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Checkbutton"):
|
||||
XFObject.__init__(self)
|
||||
@ -462,9 +553,12 @@ class Checkbutton (Button):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Bitmapbutton class
|
||||
|
||||
|
||||
class Bitmapbutton(Button):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Bitmapbutton"):
|
||||
XFObject.__init__(self)
|
||||
@ -472,9 +566,12 @@ class Bitmapbutton (Button):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Pixmapbutton class
|
||||
|
||||
|
||||
class Pixmapbutton(Button):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Pixmapbutton"):
|
||||
XFObject.__init__(self)
|
||||
@ -482,10 +579,13 @@ class Pixmapbutton (Button):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Choice Class
|
||||
# This one needs a getattr, setattr pair
|
||||
|
||||
|
||||
class Choice(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=30, l="Choice"):
|
||||
XFObject.__init__(self)
|
||||
@ -493,40 +593,57 @@ class Choice (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Clear(self):
|
||||
choice.clear(self.id)
|
||||
|
||||
def Addto(self, s):
|
||||
choice.addto(self.id, s)
|
||||
|
||||
def Replace(self, n, s):
|
||||
choice.replace(self.id, n, s)
|
||||
|
||||
def Delete(self, n):
|
||||
choice.delete(self.id, n)
|
||||
|
||||
def Set(self, n):
|
||||
choice.set(self.id, n)
|
||||
|
||||
def Settext(self, s):
|
||||
choice.set_text(self.id, s)
|
||||
|
||||
def Get(self):
|
||||
return choice.get(self.id)
|
||||
|
||||
def Getmaxitems(self):
|
||||
return choice.get_maxitems(self.id)
|
||||
|
||||
def Gettext(self):
|
||||
return choice.get_text(self.id)
|
||||
|
||||
def Setfontsize(self, n):
|
||||
choice.set_fontsize(self.id, n)
|
||||
|
||||
def Setalign(self, n):
|
||||
choice.set_align(self.id, n)
|
||||
|
||||
def Setmode(self, n, m):
|
||||
choice.set_item_mode(self.id, n, m)
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the clock class
|
||||
|
||||
|
||||
class Clock(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=90, h=90, l="Clock"):
|
||||
XFObject.__init__(self)
|
||||
self.id = clock.create(t, x, y, w, h, l)
|
||||
|
||||
def Get(self):
|
||||
return clock.get(self.id)
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the counter class
|
||||
|
||||
@ -538,22 +655,30 @@ class Counter (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Set(self, v):
|
||||
counter.set_value(self.id, v)
|
||||
|
||||
def Setbounds(self, min, max):
|
||||
counter.set_bounds(self.id, min, max)
|
||||
|
||||
def Setstep(self, s1, s2):
|
||||
counter.set_step(self.id, s1, s2)
|
||||
|
||||
def Setprecision(self, p):
|
||||
counter.set_precision(self.id, p)
|
||||
|
||||
def Get(self):
|
||||
return counter.get_value(self.id)
|
||||
|
||||
def Setreturn(self, v):
|
||||
counter.set_return(self.id, v)
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the Dial class
|
||||
|
||||
|
||||
class Dial(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=60, l="Dial"):
|
||||
XFObject.__init__(self)
|
||||
@ -561,25 +686,34 @@ class Dial (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Set(self, v):
|
||||
dial.set_value(self.id, v)
|
||||
|
||||
def Get(self):
|
||||
return dial.get_value(self.id)
|
||||
|
||||
def Setbounds(self, min, max):
|
||||
dial.set_bounds(self.id, min, max)
|
||||
|
||||
def Getbounds(self):
|
||||
return dial.get_bounds(self.id)
|
||||
|
||||
def Setstep(self, v):
|
||||
dial.set_step(self.id, v)
|
||||
|
||||
def Setreturn(self, v):
|
||||
dial.set_return(self.id, v)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Frame class
|
||||
class Frame(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=60, l="Frame"):
|
||||
XFObject.__init__(self)
|
||||
self.id = frame.create(t, x, y, w, h, l)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Input class
|
||||
|
||||
@ -591,22 +725,31 @@ class Input (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Set(self, s):
|
||||
input.set(self.id, s)
|
||||
|
||||
def Setcolor(self, c1, c2):
|
||||
input.set_color(self.id, c1, c2)
|
||||
|
||||
def Get(self):
|
||||
return input.get(self.id)
|
||||
|
||||
def Setreturn(self, v):
|
||||
input.set_return(self.id, v)
|
||||
|
||||
def Setscroll(self, v):
|
||||
input.set_scroll(self.id, v)
|
||||
|
||||
def Setcursorpos(self, x, y=1):
|
||||
input.set_cursorpos(self.id, x, y)
|
||||
|
||||
def Setselected(self, v):
|
||||
input.set_selected(self.id, v)
|
||||
|
||||
def Setselectedrange(self, x1, x2):
|
||||
input.set_selected_range(self.id, x1, x2)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name == "value":
|
||||
self.Set(value)
|
||||
@ -623,6 +766,7 @@ class Input (XFObject):
|
||||
###############################################################################
|
||||
# This is the Menu class
|
||||
|
||||
|
||||
class Menu(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=30, l="Menu"):
|
||||
XFObject.__init__(self)
|
||||
@ -630,32 +774,45 @@ class Menu (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Clear(self):
|
||||
menu.clear(self.id)
|
||||
|
||||
def Set(self, s):
|
||||
menu.set(self.id, s)
|
||||
|
||||
def Addto(self, s):
|
||||
menu.addto(self.id, s)
|
||||
|
||||
def Replace(self, n, s):
|
||||
menu.replace_item(self.id, n, s)
|
||||
|
||||
def Delete(self, n):
|
||||
menu.delete_item(self.id, n)
|
||||
|
||||
def Setshortcut(self, n, s):
|
||||
menu.set_item_shortcut(self.id, n, s)
|
||||
|
||||
def Setmode(self, n, m):
|
||||
menu.set_item_mode(self.id, n, m)
|
||||
|
||||
def Showsymbol(self, n):
|
||||
menu.show_symbol(self.id, n)
|
||||
|
||||
def Get(self):
|
||||
return menu.get(self.id)
|
||||
|
||||
def Getmaxitems(self):
|
||||
return menu.get_maxitems(self.id)
|
||||
|
||||
def Gettext(self):
|
||||
return menu.get_text(self.id)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Positioner class
|
||||
|
||||
|
||||
class Positioner(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=60, l="Positioner"):
|
||||
XFObject.__init__(self)
|
||||
@ -663,31 +820,45 @@ class Positioner (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Setx(self, v):
|
||||
positioner.set_xvalue(self.id, v)
|
||||
|
||||
def Sety(self, v):
|
||||
positioner.set_yvalue(self.id, v)
|
||||
|
||||
def Setxbounds(self, x1, x2):
|
||||
positioner.set_xbounds(self.id, x1, x2)
|
||||
|
||||
def Setybounds(self, y1, y2):
|
||||
positioner.set_ybounds(self.id, y1, y2)
|
||||
|
||||
def Setxstep(self, v):
|
||||
positioner.set_xstep(self.id, v)
|
||||
|
||||
def Setystep(self, v):
|
||||
positioner.set_ystep(self.id, v)
|
||||
|
||||
def Getx(self):
|
||||
return positioner.get_xvalue(self.id)
|
||||
|
||||
def Gety(self):
|
||||
return positioner.get_yvalue(self.id)
|
||||
|
||||
def Getxbounds(self):
|
||||
positioner.get_xbounds(self.id)
|
||||
|
||||
def Getybounds(self):
|
||||
positioner.get_ybounds(self.id)
|
||||
|
||||
def Setreturn(self, v):
|
||||
positioner.set_return(self.id, v)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Slider class
|
||||
|
||||
|
||||
class Slider(XFObject):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=30, l="Slider"):
|
||||
XFObject.__init__(self)
|
||||
@ -695,24 +866,33 @@ class Slider (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Get(self):
|
||||
return slider.get_value(self.id)
|
||||
|
||||
def Set(self, v):
|
||||
slider.set_value(self.id, v)
|
||||
|
||||
def Getbounds(self):
|
||||
return slider.get_bounds(self.id)
|
||||
|
||||
def Setbounds(self, v1, v2):
|
||||
slider.set_bounds(self.id, v1, v2)
|
||||
|
||||
def Setreturn(self, v):
|
||||
slider.set_return(self.id, v)
|
||||
|
||||
def Setstep(self, v):
|
||||
slider.set_step(self.id, v)
|
||||
|
||||
def Setsize(self, v):
|
||||
slider.set_size(self.id, v)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# This is the Valslider class
|
||||
|
||||
|
||||
class Valslider(Slider):
|
||||
def __init__(self, t=0, x=10, y=10, w=60, h=30, l="Valslider"):
|
||||
XFObject.__init__(self)
|
||||
@ -720,12 +900,15 @@ class Valslider (Slider):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Setprecision(self, v):
|
||||
slider.set_precision(self.id, v)
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the Timer class
|
||||
|
||||
|
||||
class Timer(XFObject):
|
||||
def __init__(self, t=1, x=10, y=10, w=60, h=30, l="Timer"):
|
||||
XFObject.__init__(self)
|
||||
@ -733,7 +916,9 @@ class Timer (XFObject):
|
||||
_objects[str(self.id)] = self
|
||||
self.cb = _nocb
|
||||
self.args = self
|
||||
|
||||
def Set(self, v):
|
||||
timer.set(self.id, v)
|
||||
|
||||
def Get(self):
|
||||
return timer.get(self.id)
|
||||
|
@ -5,7 +5,7 @@ from Pyxform import *
|
||||
# Init the library (sucks but works)
|
||||
#
|
||||
|
||||
xfinit ('Something','1',sys.argv[0])
|
||||
xfinit("Something", "1", sys.argv[0])
|
||||
|
||||
#
|
||||
# Create a "Window" - A form in XForms parlance
|
||||
|
@ -7,7 +7,7 @@ from goodies import *
|
||||
# Init the library (sucks but works)
|
||||
#
|
||||
|
||||
xfinit ('Something','1',sys.argv[0])
|
||||
xfinit("Something", "1", sys.argv[0])
|
||||
|
||||
#
|
||||
# Create a "Window" - A form in XForms parlance
|
||||
@ -32,12 +32,14 @@ win.Add (a_button)
|
||||
#
|
||||
# Define a function, that will be executed when the button is pressed
|
||||
|
||||
|
||||
def funct(self):
|
||||
# It shows a message and exits (or not)
|
||||
answer = show_question("Do you want", "to exit?", "")
|
||||
if answer == 1:
|
||||
sys.exit()
|
||||
|
||||
|
||||
#
|
||||
# And bind the function to the button
|
||||
|
||||
|
@ -7,7 +7,7 @@ from goodies import *
|
||||
# Init the library (sucks but works)
|
||||
#
|
||||
|
||||
xfinit ('Something','1',sys.argv[0])
|
||||
xfinit("Something", "1", sys.argv[0])
|
||||
|
||||
#
|
||||
# Create a "Window" - A form in XForms parlance
|
||||
@ -45,22 +45,24 @@ win.Add (v_slider)
|
||||
#
|
||||
# Define a function, that will be executed when the button is pressed
|
||||
|
||||
|
||||
def funct(self):
|
||||
# It shows a message and exits (or not)
|
||||
answer = show_question("Do you want", "to exit?", "")
|
||||
if answer == 1:
|
||||
sys.exit()
|
||||
|
||||
|
||||
#
|
||||
# And another one, for when the sliders move
|
||||
|
||||
|
||||
def slide(self):
|
||||
# It moves the button to the position of the sliders
|
||||
a_button.x = h_slider.Get()
|
||||
a_button.y = v_slider.Get()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# And bind the functions to the controls
|
||||
|
||||
|
@ -7,7 +7,7 @@ from goodies import *
|
||||
# Init the library (sucks but works)
|
||||
#
|
||||
|
||||
xfinit ('Something','1',sys.argv[0])
|
||||
xfinit("Something", "1", sys.argv[0])
|
||||
|
||||
#
|
||||
# Create a "Window" - A form in XForms parlance
|
||||
@ -47,22 +47,24 @@ win.Add (v_slider)
|
||||
#
|
||||
# Define a function, that will be executed when the button is pressed
|
||||
|
||||
|
||||
def funct(self):
|
||||
# It shows a message and exits (or not)
|
||||
answer = show_question("Do you want", "to exit?", "")
|
||||
if answer == 1:
|
||||
sys.exit()
|
||||
|
||||
|
||||
#
|
||||
# And another one, for when the sliders move
|
||||
|
||||
|
||||
def slide(self):
|
||||
# It moves the button to the position of the sliders
|
||||
a_button.x = h_slider.Get()
|
||||
a_button.y = v_slider.Get()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# And bind the functions to the controls
|
||||
|
||||
|
@ -7,7 +7,7 @@ from goodies import *
|
||||
# Init the library (sucks but works)
|
||||
#
|
||||
|
||||
xfinit ('Something','1',sys.argv[0])
|
||||
xfinit("Something", "1", sys.argv[0])
|
||||
|
||||
#
|
||||
# Create a "Window" - A form in XForms parlance
|
||||
@ -35,21 +35,26 @@ win.Add (but2)
|
||||
#
|
||||
# The exit function
|
||||
|
||||
|
||||
def funct(self):
|
||||
# It shows a message and exits (or not)
|
||||
answer = show_question("Do you want", "to exit?", "")
|
||||
if answer == 1:
|
||||
sys.exit()
|
||||
|
||||
|
||||
but2.cb = funct
|
||||
|
||||
#
|
||||
# And the interesting function
|
||||
|
||||
|
||||
def browse_file(self):
|
||||
# Asks for a file, and puts it in the browser
|
||||
filename = show_fselector("", "", "", "")
|
||||
brow.Load(filename)
|
||||
|
||||
|
||||
but1.cb = browse_file
|
||||
|
||||
|
||||
|
258
setup.py
258
setup.py
@ -1,99 +1,167 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from setuptools import setup, Extension
|
||||
|
||||
bitmaps = Extension('Pyxform.bitmaps',
|
||||
sources = [ 'Pyxform/Modules/bitmaps.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
box = Extension('Pyxform.box',
|
||||
sources = [ 'Pyxform/Modules/box.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
browser = Extension('Pyxform.browser',
|
||||
sources = [ 'Pyxform/Modules/browser.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
button = Extension('Pyxform.button',
|
||||
sources = [ 'Pyxform/Modules/button.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
choice = Extension('Pyxform.choice',
|
||||
sources = [ 'Pyxform/Modules/choice.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
clock = Extension('Pyxform.clock',
|
||||
sources = [ 'Pyxform/Modules/clock.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
counter = Extension('Pyxform.counter',
|
||||
sources = [ 'Pyxform/Modules/counter.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
dial = Extension('Pyxform.dial',
|
||||
sources = [ 'Pyxform/Modules/dial.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
forms = Extension('Pyxform.forms',
|
||||
sources = [ 'Pyxform/Modules/forms.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
frame = Extension('Pyxform.frame',
|
||||
sources = [ 'Pyxform/Modules/frame.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
goodies = Extension('Pyxform.goodies',
|
||||
sources = [ 'Pyxform/Modules/goodies.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
input = Extension('Pyxform.input',
|
||||
sources = [ 'Pyxform/Modules/input.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
menu = Extension('Pyxform.menu',
|
||||
sources = [ 'Pyxform/Modules/menu.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
objects = Extension('Pyxform.objects',
|
||||
sources = [ 'Pyxform/Modules/objects.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
pixmaps = Extension('Pyxform.pixmaps',
|
||||
sources = [ 'Pyxform/Modules/pixmaps.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
popups = Extension('Pyxform.popups',
|
||||
sources = [ 'Pyxform/Modules/popups.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
positioner = Extension('Pyxform.positioner',
|
||||
sources = [ 'Pyxform/Modules/positioner.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
slider = Extension('Pyxform.slider',
|
||||
sources = [ 'Pyxform/Modules/slider.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
text = Extension('Pyxform.text',
|
||||
sources = [ 'Pyxform/Modules/text.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
timer = Extension('Pyxform.timer',
|
||||
sources = [ 'Pyxform/Modules/timer.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
xforms = Extension('Pyxform.xforms',
|
||||
sources = [ 'Pyxform/Modules/xforms.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
xyplot = Extension('Pyxform.xyplot',
|
||||
sources = [ 'Pyxform/Modules/xyplot.c'],
|
||||
libraries = ['forms'],
|
||||
library_dirs = ['/usr/local/lib'])
|
||||
setup (name = 'PyXForms',
|
||||
version = '0.2',
|
||||
description = 'This is OLD code',
|
||||
author = 'Roberto Alsina',
|
||||
author_email = 'ralsina@netmanagers.com.ar',
|
||||
ext_modules = [bitmaps, box, browser, button, choice, clock, counter, dial, forms, frame, goodies, input, menu, objects, pixmaps, popups, positioner, slider, text, timer, xforms, xyplot],
|
||||
packages = ['Pyxform']
|
||||
bitmaps = Extension(
|
||||
"Pyxform.bitmaps",
|
||||
sources=["Pyxform/Modules/bitmaps.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
box = Extension(
|
||||
"Pyxform.box",
|
||||
sources=["Pyxform/Modules/box.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
browser = Extension(
|
||||
"Pyxform.browser",
|
||||
sources=["Pyxform/Modules/browser.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
button = Extension(
|
||||
"Pyxform.button",
|
||||
sources=["Pyxform/Modules/button.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
choice = Extension(
|
||||
"Pyxform.choice",
|
||||
sources=["Pyxform/Modules/choice.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
clock = Extension(
|
||||
"Pyxform.clock",
|
||||
sources=["Pyxform/Modules/clock.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
counter = Extension(
|
||||
"Pyxform.counter",
|
||||
sources=["Pyxform/Modules/counter.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
dial = Extension(
|
||||
"Pyxform.dial",
|
||||
sources=["Pyxform/Modules/dial.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
forms = Extension(
|
||||
"Pyxform.forms",
|
||||
sources=["Pyxform/Modules/forms.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
frame = Extension(
|
||||
"Pyxform.frame",
|
||||
sources=["Pyxform/Modules/frame.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
goodies = Extension(
|
||||
"Pyxform.goodies",
|
||||
sources=["Pyxform/Modules/goodies.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
input = Extension(
|
||||
"Pyxform.input",
|
||||
sources=["Pyxform/Modules/input.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
menu = Extension(
|
||||
"Pyxform.menu",
|
||||
sources=["Pyxform/Modules/menu.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
objects = Extension(
|
||||
"Pyxform.objects",
|
||||
sources=["Pyxform/Modules/objects.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
pixmaps = Extension(
|
||||
"Pyxform.pixmaps",
|
||||
sources=["Pyxform/Modules/pixmaps.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
popups = Extension(
|
||||
"Pyxform.popups",
|
||||
sources=["Pyxform/Modules/popups.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
positioner = Extension(
|
||||
"Pyxform.positioner",
|
||||
sources=["Pyxform/Modules/positioner.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
slider = Extension(
|
||||
"Pyxform.slider",
|
||||
sources=["Pyxform/Modules/slider.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
text = Extension(
|
||||
"Pyxform.text",
|
||||
sources=["Pyxform/Modules/text.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
timer = Extension(
|
||||
"Pyxform.timer",
|
||||
sources=["Pyxform/Modules/timer.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
xforms = Extension(
|
||||
"Pyxform.xforms",
|
||||
sources=["Pyxform/Modules/xforms.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
xyplot = Extension(
|
||||
"Pyxform.xyplot",
|
||||
sources=["Pyxform/Modules/xyplot.c"],
|
||||
libraries=["forms"],
|
||||
library_dirs=["/usr/local/lib"],
|
||||
)
|
||||
setup(
|
||||
name="PyXForms",
|
||||
version="0.2",
|
||||
description="This is OLD code",
|
||||
author="Roberto Alsina",
|
||||
author_email="ralsina@netmanagers.com.ar",
|
||||
ext_modules=[
|
||||
bitmaps,
|
||||
box,
|
||||
browser,
|
||||
button,
|
||||
choice,
|
||||
clock,
|
||||
counter,
|
||||
dial,
|
||||
forms,
|
||||
frame,
|
||||
goodies,
|
||||
input,
|
||||
menu,
|
||||
objects,
|
||||
pixmaps,
|
||||
popups,
|
||||
positioner,
|
||||
slider,
|
||||
text,
|
||||
timer,
|
||||
xforms,
|
||||
xyplot,
|
||||
],
|
||||
packages=["Pyxform"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user