Compare commits

...

6 Commits

Author SHA1 Message Date
a8efd1c3e1 Fix examples a bit 2024-06-03 18:07:23 -03:00
ce9cd97bda updated README 2024-06-03 18:01:48 -03:00
7340f72ae2 No more vmode 2024-06-03 17:59:38 -03:00
f2057962ff In Python3 we need to return the module 2024-06-03 17:57:27 -03:00
ca2dc8f9cf Reorg'd code, doesn't work 2024-06-03 17:43:14 -03:00
fcdb8a28b3 Reorg'd code, doesn't work 2024-06-03 17:42:43 -03:00
37 changed files with 305 additions and 858 deletions

162
.gitignore vendored Normal file
View File

@ -0,0 +1,162 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

View File

@ -1,739 +0,0 @@
##########################################################
# This is the Python interface to the pyxforms C module
#
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
###############################################################################
# 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
class Form:
def __init__(self,t=6,w=200,h=200):
self.id=forms.create (0,w,h)
self.__box=Box(t,0,0,w,h,"")
self.Add (self.__box)
self.__box.c1=11
self.__box.c2=15
self.__minx=1 # Reasonable defaults for things that
self.__miny=1 # I can't get from XForms
self.__maxx=10000 # Notice that if the C code changes them
self.__maxy=10000 # They get out of sync!
self.__title=sys.argv[0] #the "preferred" form title
self.__placement=16388
self.__decoration=1
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)
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)
def __setattr__(self,name,value):
if name=="x":
(tx,ty,tw,th)=forms.get_geometry (self.id)
forms.set_geometry (self.id,value,ty,tw,th)
elif name=="y":
(tx,ty,tw,th)=forms.get_geometry (self.id)
forms.set_geometry (self.id,tx,value,tw,th)
elif name=="w":
(tx,ty,tw,th)=forms.get_geometry (self.id)
forms.set_geometry (self.id,tx,ty,value,th)
elif name=="h":
(tx,ty,tw,th)=forms.get_geometry (self.id)
forms.set_geometry (self.id,tx,ty,tw,value)
elif name=="dblbuffer":
forms.set_dblbuffer(self.id,value)
elif name=="frozen":
if value:
self.Freeze()
else:
self.Unfreeze()
elif name=="active":
if value:
self.Activate()
else:
self.Deactivate()
elif name=="visible":
if value:
self.Show()
else:
self.Hide()
elif name=="minx":
self.Setminsize (value,self.__miny)
elif name=="miny":
self.Setminsize (self.__minx,value)
elif name=="maxx":
self.Setminsize (value,self.__maxy)
elif name=="maxy":
self.Setminsize (self.__maxx,value)
elif name=="title":
self.Settitle (value)
elif name=="c1":
self.__box.c1=value
elif name=="c2":
self.__box.c2=value
else:
self.__dict__ [name]=value
def __getattr__(self,name):
if name=="x":
(tx,ty,tw,th)=forms.get_geometry (self.id)
return tx
elif name=="y":
(tx,ty,tw,th)=forms.get_geometry (self.id)
return ty
elif name=="w":
(tx,ty,tw,th)=forms.get_geometry (self.id)
return tw
elif name=="h":
(tx,ty,tw,th)=forms.get_geometry (self.id)
return th
elif name=="minx":
return self.__minx
elif name=="miny":
return self.__miny
elif name=="maxx":
return self.__maxx
elif name=="maxy":
return self.__maxy
elif name=="vmode":
(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)
return active
elif name=="dblbuffer":
(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)
return frozen
elif name=="visible":
(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)
return border
elif name=="other":
(vmode,active,dblbuffer,frozen,visible,border,other)=forms.get_attr(self.id)
return other
elif name=="title":
return self.Gettitle ()
elif name=="c1":
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)
###############################################################################
#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)
elif name=="bw":
objects.set_bw (self.id,value)
elif name=="labelsize":
objects.set_ls (self.id,value)
elif name=="labelstyle":
objects.set_lstyle (self.id,value)
elif name=="labelcolor":
objects.set_lcol (self.id,value)
elif name=="labelalign":
objects.set_lalign (self.id,value)
elif name=="label":
objects.set_label (self.id,value)
elif name=="shortcut":
objects.set_shortcut (self.id,value,1)
elif name=="dblbuffer":
objects.set_dblbuffer(self.id,value)
elif name=="x":
(tx,ty,tw,th)=objects.get_geometry (self.id)
objects.set_geometry (self.id,value,ty,tw,th)
elif name=="y":
(tx,ty,tw,th)=objects.get_geometry (self.id)
objects.set_geometry (self.id,tx,value,tw,th)
elif name=="w":
(tx,ty,tw,th)=objects.get_geometry (self.id)
objects.set_geometry (self.id,tx,ty,value,th)
elif name=="h":
(tx,ty,tw,th)=objects.get_geometry (self.id)
objects.set_geometry (self.id,tx,ty,tw,value)
elif name=="resize":
objects.set_resize (self.id,value)
elif name=="c1":
self.Setcolor (value,self.__c2)
elif name=="c2":
self.Setcolor (self.__c1,value)
else:
self.__dict__ [name]=value
def __getattr__(self,name):
if name=="c1":
return self.__c1
elif name=="c2":
return self.__c2
def __del__ (self):
#probably a BAD idea
objects.free(self.id)
###############################################################################
# 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)
elif name=="foreground":
objects.set_lcol(self.id,value)
else:
XFObject.__setattr__(self,name,value)
###############################################################################
# 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)
elif name=="foreground":
objects.set_lcol(self.id,value)
else:
XFObject.__setattr__(self,name,value)
###############################################################################
# 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)
self.id=browser.create(t,x,y,w,h,l)
_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)
elif name=="specialkey":
self.Setspecialkey(value)
elif name=="fontstyle":
self.Setfontstyle(value)
elif name=="fontsize":
self.Setfontsize(value)
elif name=="topline":
self.Settopline(value)
else:
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)
self.id=button.create(t,x,y,w,h,l)
_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
# b(1) or b(0) SETS the button value.
# You can also set/get it with b.value, though
if v==-1:
return button.get(self.id)
else:
button.set (self.id,v)
def __setattr__ (self,name,value):
if name=="value":
self(value)
else:
XFObject.__setattr__(self,name,value)
def __getattr__ (self,name):
if name=="value":
return self()
elif name=="numb":
return button.get_numb (self.id)
pass
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)
self.id=button.create_round(t,x,y,w,h,l)
_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)
self.id=button.create_light(t,x,y,w,h,l)
_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)
self.id=button.create_check(t,x,y,w,h,l)
_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)
self.id=button.create_bitmap(t,x,y,w,h,l)
_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)
self.id=button.create_pixmap(t,x,y,w,h,l)
_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)
self.id=choice.create(t,x,y,w,h,l)
_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
class Counter (XFObject):
def __init__(self,t=0,x=10,y=10,w=90,h=30,l="Counter"):
XFObject.__init__ (self)
self.id=counter.create(t,x,y,w,h,l)
_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)
self.id=dial.create(t,x,y,w,h,l)
_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
class Input (XFObject):
def __init__(self,t=0,x=10,y=10,w=60,h=30,l="Input"):
XFObject.__init__ (self)
self.id=input.create(t,x,y,w,h,l)
_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)
else:
XFObject.__setattr__(self,name,value)
def __getattr__ (self,name):
if name=="value":
return self.Get()
else:
return XFObject.__getattr__(self,name)
###############################################################################
# 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)
self.id=menu.create(t,x,y,w,h,l)
_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)
self.id=positioner.create(t,x,y,w,h,l)
_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)
self.id=slider.create(t,x,y,w,h,l)
_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)
self.id=slider.create_val(t,x,y,w,h,l)
_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)
self.id=timer.create(t,x,y,w,h,l)
_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)

View File

@ -1,4 +1,4 @@
This is the 0.1 Alpha release pf pyxform, my interface between Python 1.3
This is the 0.3 Alpha release pf pyxform, my interface between Python
And The XForms library.
You need:
@ -7,33 +7,26 @@ A standard Unix, whit X-window, and Xpm library
I only tested it under Linux (it used to be a Slackware 3.0 ELF), but
should do well under anything XForms and Python work.
XForms 0.8
XForms 1.24 or later
It's a free-for-non-commercial-use Widget library for X11
you can get it at:
http://bragg.phys.uwm.edu/xforms
BE CAREFUL: YOU NEED THE 0.80 beta, not the 0.75 official.
http://xforms-toolkit.org
Python 1.3
Python 3.8 or later
It's a beautiful ,free, language.
Get it from
ftp://ftp.python.org
http://www.python.org
It's still fairly incomplete, mainly because of lack of free time, but it
is functional.
Also, it only covers the functionality of XForms 0.8, any new widgets or
methods added after that are not wrapped.
I tried to provide the easiest possible way to make a GUI for python under
UNIX, and think it's ready to be seen.
Sadly, there are no docs, yet, but the examples should be enough to get a
taste of the module, and the source should be readable.
To add it to your Python, put the *.c files in the Modules directory in
Python-1.3/Modules.
Add Modules/Setup.pyxform at the end of your Python-1.3/Modules/Setup file,
and edit it for your site.
BTW: If anyone likes it, email me at ralsina@unl.edu.ar
And for those non-unix people: Dr Zhao (The XForms author) say the next
version will have win32 support....
BTW: If anyone likes it, email me at roberto.alsina@gmail.com

View File

@ -7,12 +7,8 @@ In order to fully understand this (and use the hundreds of things not
demonstrated), you should:
a) Read the XForms docs
b) Read the Pyxform.py file
b) Read the pyxforms/__init__.py file
c) Read all the .c files
Anyway, it's just a sampler, this should get MUCH more complete soon
Anyway, you can email me
Roberto Alsina
ralsina@unl.edu.ar

View File

@ -1,5 +1,5 @@
#!/usr/local/bin/python
from Pyxform import *
#!/usr/bin/env python
from pyxforms import *
#
# Init the library (sucks but works)

View File

@ -1,7 +1,7 @@
#!/usr/local/bin/python
#!/usr/bin/env python
from Pyxform import *
from goodies import *
from pyxforms import *
from pyxforms.goodies import *
#
# Init the library (sucks but works)
@ -35,7 +35,7 @@ win.Add(a_button)
def funct(self):
# It shows a message and exits (or not)
answer = show_question("Do you want", "to exit?", "")
answer = show_question("Do you want to exit?", "")
if answer == 1:
sys.exit()

View File

@ -1,7 +1,7 @@
#!/usr/local/bin/python
#!/usr/bin/env python
from Pyxform import *
from goodies import *
from pyxforms import *
from pyxforms.goodies import *
#
# Init the library (sucks but works)

View File

@ -1,7 +1,8 @@
#!/usr/local/bin/python
#!/usr/bin/env python
from Pyxform import *
from goodies import *
from pyxforms import *
from pyxforms.goodies import *
#
# Init the library (sucks but works)

View File

@ -1,6 +1,6 @@
#!/usr/local/bin/python
from Pyxform import *
from pyxforms import *
from goodies import *
#

24
pyproject.toml Normal file
View File

@ -0,0 +1,24 @@
[project]
name = "pyxforms"
version = "0.3.0"
description = "A Python binding for XForms"
authors = [
{ name = "Roberto Alsina", email = "roberto.alsina@gmail.com" }
]
dependencies = []
readme = "README.md"
requires-python = ">= 3.8"
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.rye]
managed = true
dev-dependencies = []
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["src/pyxforms"]

11
requirements-dev.lock Normal file
View File

@ -0,0 +1,11 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
-e file:.

11
requirements.lock Normal file
View File

@ -0,0 +1,11 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
-e file:.

View File

@ -1,5 +0,0 @@
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0

116
setup.py
View File

@ -2,143 +2,116 @@
from setuptools import setup, Extension
bitmaps = Extension(
"Pyxform.bitmaps",
sources=["Pyxform/Modules/bitmaps.c"],
name="pyxforms.bitmaps",
sources=["src/pyxforms/bitmaps.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
box = Extension(
"Pyxform.box",
sources=["Pyxform/Modules/box.c"],
name="pyxforms.box",
sources=["src/pyxforms/box.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
browser = Extension(
"Pyxform.browser",
sources=["Pyxform/Modules/browser.c"],
name="pyxforms.browser",
sources=["src/pyxforms/browser.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
button = Extension(
"Pyxform.button",
sources=["Pyxform/Modules/button.c"],
name="pyxforms.button",
sources=["src/pyxforms/button.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
choice = Extension(
"Pyxform.choice",
sources=["Pyxform/Modules/choice.c"],
name="pyxforms.choice",
sources=["src/pyxforms/choice.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
clock = Extension(
"Pyxform.clock",
sources=["Pyxform/Modules/clock.c"],
name="pyxforms.clock",
sources=["src/pyxforms/clock.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
counter = Extension(
"Pyxform.counter",
sources=["Pyxform/Modules/counter.c"],
name="pyxforms.counter",
sources=["src/pyxforms/counter.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
dial = Extension(
"Pyxform.dial",
sources=["Pyxform/Modules/dial.c"],
name="pyxforms.dial",
sources=["src/pyxforms/dial.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
forms = Extension(
"Pyxform.forms",
sources=["Pyxform/Modules/forms.c"],
name="pyxforms.forms",
sources=["src/pyxforms/forms.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
frame = Extension(
"Pyxform.frame",
sources=["Pyxform/Modules/frame.c"],
name="pyxforms.frame",
sources=["src/pyxforms/frame.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
goodies = Extension(
"Pyxform.goodies",
sources=["Pyxform/Modules/goodies.c"],
name="pyxforms.goodies",
sources=["src/pyxforms/goodies.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
input = Extension(
"Pyxform.input",
sources=["Pyxform/Modules/input.c"],
name="pyxforms.input",
sources=["src/pyxforms/input.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
menu = Extension(
"Pyxform.menu",
sources=["Pyxform/Modules/menu.c"],
name="pyxforms.menu",
sources=["src/pyxforms/menu.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
objects = Extension(
"Pyxform.objects",
sources=["Pyxform/Modules/objects.c"],
name="pyxforms.objects",
sources=["src/pyxforms/objects.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
pixmaps = Extension(
"Pyxform.pixmaps",
sources=["Pyxform/Modules/pixmaps.c"],
name="pyxforms.pixmaps",
sources=["src/pyxforms/pixmaps.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
popups = Extension(
"Pyxform.popups",
sources=["Pyxform/Modules/popups.c"],
name="pyxforms.popups",
sources=["src/pyxforms/popups.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
positioner = Extension(
"Pyxform.positioner",
sources=["Pyxform/Modules/positioner.c"],
name="pyxforms.positioner",
sources=["src/pyxforms/positioner.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
slider = Extension(
"Pyxform.slider",
sources=["Pyxform/Modules/slider.c"],
name="pyxforms.slider",
sources=["src/pyxforms/slider.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
text = Extension(
"Pyxform.text",
sources=["Pyxform/Modules/text.c"],
name="pyxforms.text",
sources=["src/pyxforms/text.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
timer = Extension(
"Pyxform.timer",
sources=["Pyxform/Modules/timer.c"],
name="pyxforms.timer",
sources=["src/pyxforms/timer.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
xforms = Extension(
"Pyxform.xforms",
sources=["Pyxform/Modules/xforms.c"],
name="pyxforms.xforms",
sources=["src/pyxforms/xforms.c"],
libraries=["forms"],
library_dirs=["/usr/local/lib"],
)
xyplot = Extension(
"Pyxform.xyplot",
sources=["Pyxform/Modules/xyplot.c"],
name="pyxforms.xyplot",
sources=["src/pyxforms/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,
@ -163,5 +136,4 @@ setup(
xforms,
xyplot,
],
packages=["Pyxform"],
)

View File

@ -196,37 +196,37 @@ class Form:
elif name == "maxy":
return self.__maxy
elif name == "vmode":
(vmode, active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
(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(
(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(
(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(
(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(
(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(
(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(
(active, dblbuffer, frozen, visible, border, other) = forms.get_attr(
self.id
)
return other

View File

@ -138,4 +138,5 @@ PyInit_bitmaps()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module bitmaps");
return m;
}

View File

@ -95,5 +95,6 @@ PyInit_box()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module box");
return m;
}

View File

@ -492,5 +492,6 @@ PyInit_browser()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module browser");
return m;
}

View File

@ -375,5 +375,6 @@ PyInit_button()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module button");
return m;
}

View File

@ -351,5 +351,6 @@ PyInit_choice()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module choice");
return m;
}

View File

@ -112,5 +112,6 @@ PyInit_clock()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module clock");
return m;
}

View File

@ -210,5 +210,6 @@ PyInit_counter()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module counter");
return m;
}

View File

@ -210,5 +210,6 @@ PyInit_dial()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module dial");
return m;
}

View File

@ -681,7 +681,7 @@ static struct PyModuleDef moduledef =
};
PyMODINIT_FUNC
PyInit_forms()
PyInit_forms(void)
{
PyObject *m, *d;
@ -698,5 +698,6 @@ PyInit_forms()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module forms");
return m;
}

View File

@ -93,5 +93,6 @@ PyInit_frame()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module frame");
return m;
}

View File

@ -505,5 +505,6 @@ PyInit_goodies()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module goodies");
return m;
}

View File

@ -252,5 +252,6 @@ PyInit_input()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module input");
return m;
}

View File

@ -312,5 +312,6 @@ PyInit_menu()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module menu");
return m;
}

View File

@ -519,5 +519,6 @@ PyInit_objects()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module objects");
return m;
}

View File

@ -136,5 +136,6 @@ PyInit_pixmaps()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module pixmaps");
return m;
}

View File

@ -379,5 +379,6 @@ PyInit_popups()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module popups");
return m;
}

View File

@ -311,5 +311,6 @@ PyInit_positioner()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module positioner");
return m;
}

View File

@ -272,5 +272,6 @@ PyInit_slider()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module slider");
return m;
}

View File

@ -91,5 +91,6 @@ PyInit_text()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module text");
return m;
}

View File

@ -132,5 +132,6 @@ PyInit_timer()
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module timer");
return m;
}

View File

@ -85,6 +85,6 @@ static struct PyModuleDef moduledef =
PyMODINIT_FUNC
PyInit_xforms()
{
PyModule_Create(&moduledef);
return PyModule_Create(&moduledef);
}

View File

@ -448,4 +448,5 @@ PyInit_xyplot ()
/* Check for errors */
if (PyErr_Occurred ())
Py_FatalError ("can't initialize module xyplot");
return m;
}