Esempio n. 1
0
def figure8():
    print 'Figure 17.6'

    g = Gui()
    options = dict(side=TOP, fill=X)

    # create the widgets
    g.fr()
    la = g.la(side=TOP, text='List of colors:')
    lb = g.lb(side=LEFT)
    sb = g.sb(side=RIGHT, fill=Y)
    g.endfr()

    bu = g.bu(side=BOTTOM, text='OK', command=g.quit)

    # fill the listbox with color names
    colors = []
    for line in open('/etc/X11/rgb.txt'):
        t = line.split('\t')
        name = t[-1].strip()
        colors.append(name)

    for color in colors:
        lb.insert(END, color)

    # tell the listbox and the scrollbar about each other
    lb.configure(yscrollcommand=sb.set)
    sb.configure(command=lb.yview)

    g.mainloop()
    g.destroy()
Esempio n. 2
0
    def test_canvas(self):
        gui = Gui.Gui()
        ca = gui.ca()
        self.assertEqual(ca.width, 100)
        self.assertEqual(ca.height, 100)

        point = [50, 50]
        box = [[100, 200], [300, 500]]
        item = ca.arc(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.line(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.oval(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.circle(point, 25)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.polygon(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.rectangle(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.text(point, 'text')
        self.assertTrue(isinstance(item, Gui.Item))
Esempio n. 3
0
def make_gui():

    global g

    g = Gui()

    g.title('Chapter 19 Section 2 Excercise 1')
Esempio n. 4
0
def figure1():
    print 'Figure 17.3 a'

    g = Gui()
    b1 = g.bu(text='OK', command=g.quit)
    b2 = g.bu(text='Cancel')
    b3 = g.bu(text='Help')

    g.mainloop()
Esempio n. 5
0
def make_gui():

    global g
    g = Gui()
    g.title('Chapter 19 Section 5 Excercise 3')

    global canvas
    canvas = g.ca(width=500, height=500)
    canvas.config(bg='black')
Esempio n. 6
0
def figure4():
    print 'Figure 17.4 a'

    g = Gui()
    options = dict(side=LEFT, padx=10, pady=10)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
Esempio n. 7
0
def figure7():
    print 'Figure 17.5'

    g = Gui()
    options = dict(side=TOP, fill=X)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel Command', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
    g.destroy()
Esempio n. 8
0
def figure9():
    print 'Figure 17.7 a'

    g = Gui()
    options = dict(side=LEFT)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel', **options)
    b3 = g.bu(text='Help', **options)

    g.geometry('300x150')
    g.mainloop()
 def __init__(self, myMap = None, title = None, *colors):
     if myMap == None:
         self._map = getDefaultPBNMap()
     elif isinstance(myMap, PBNMap):
         self._map = myMap
     else:
         raise TypeError("myMap must be a PBN map or None")
     self._viewMap = PBNMap(self._map.dims())
     self._colors = ["white", "black"] + [c for c in colors] + ["x"]
     self._gui = Gui() ##From Swampy
     self._view = PBNViewController(self._map.dims(), self._gui, title, *colors)
     self._view.setup([self.getRowList(i) for i in range(self._map.dims()[0])],
                      [self.getColList(j) for j in range(self._map.dims()[0])],
                      self._viewMap, self._controller)
Esempio n. 10
0
    def test_gui(self):
        gui = Gui.Gui()
        fr = gui.fr()
        endfr = gui.endfr()
        self.assertEqual(gui, endfr)

        row = gui.row()
        gui.rowweights([1, 2, 3])

        col = gui.col()
        gui.colweights([1, 2, 3])

        popfr = gui.popfr()

        self.assertEqual(popfr, row)

        en = gui.en()

        ca = gui.ca()
        self.assertTrue(isinstance(ca, Gui.GuiCanvas))

        la = gui.la()

        widget = gui.la()
        widget = gui.lb()
        widget = gui.bu()

        mb = gui.mb()
        widget = gui.mi(mb)

        widget = gui.te()
        widget = gui.sb()
        widget = gui.cb()

        size = tkinter.IntVar()
        widget = gui.rb(variable=size, value=1)

        widget = gui.st()
        self.assertTrue(isinstance(widget, Gui.Gui.ScrollableText))

        widget = gui.sc()
        self.assertTrue(isinstance(widget, Gui.Gui.ScrollableCanvas))

        gui.destroy()
Esempio n. 11
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# encoding=utf8

import swampy.Gui as spy


def hello():
    """
    It is a docstring.
	"""
    ca.text([0, 0], 'hello', 'blue')


gui = spy.Gui()
gui.row()
ca = gui.ca(bg='white')
print hello.__doc__
gui.col()
gui.bu(text='Hello', command=hello)
gui.bu(text='Quit', command=gui.quit)
gui.endcol()
gui.endrow()
gui.mainloop()
Esempio n. 12
0
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html

This program requires Gui.py, which is part of
Swampy; you can download it from thinkpython.com/swampy.

This program demonstrates how to use the Gui module
to create and operate on Tkinter widgets.

The documentation for the widgets is at
http://www.pythonware.com/library/tkinter/introduction/
"""

from swampy.Gui import *

# create the Gui: the debug flag makes the frames visible
g = Gui(debug=False)

# the topmost structure is a row of widgets
g.row()

# FRAME 1

# the first frame is a column of widgets
g.col()

# la is for label
la1 = g.la(text='This is a label.')

# en is for entry
en = g.en()
en.insert(END, 'This is an entry widget.')
Esempio n. 13
0
def make_gui():

    global g
    g = Gui()
    g.title('Chapter 19 Excercise 2')
Esempio n. 14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# from Gui import *
from swampy.Gui import *




if __name__ == '__main__':
	gui = Gui()
	canv = gui.config(bg='white')
	canv2 = canv.
Esempio n. 15
0
from swampy.Gui import *

g = Gui()
g.title('Gui')
g.mainloop()

button = g.bu(text='Press me.')
label = g.la(text='Press the button')


def make_label():
    g.la(text='Thank you')


button2 = g.bu(text='No, press me!', command=make_label)

# canvas widgets
canvas = g.ca(width=500, height=500)
# width and height are dimensions in pixels
canvas.config(bg='white')
# value of bg is a string that names a color
# shapes on canvas are called items
item = canvas.circle([0, 0], 100, fill='red')
# first arg is a coordinate pair, that specifices the center of the circle
# 2nd arg is radius
item.config(fill='yellow', outline='orange', width=10)
# coordinate sequences
canvas.rectangle([0, 0], [200, 200], fill='blue', outline='orange', width=10)
# oval takes a bounding box and draws an oval within rectangle
canvas.oval([[0, 0], [200, 100]], outline='orange', width=10)
canvas.line([[0, 100], [100, 200], [200, 100]], width=10)
Esempio n. 16
0
from swampy import Gui

# create some new Gui object
g = Gui.Gui()

# give it a title
g.title('Gui')

# create a label widget
label = g.la(text='Press the button.')

# add a button
g.bu(text='Press me!')


# add another button
def make_label():
    g.la(text='Thank you.')


button2 = g.bu(text='No, press me!', command=make_label)

# allows user to enter a single line of text
entry = g.en(text='Default text.')

# allows user to enter multiple lines of text
text = g.te(width=100, height=5)
text.insert(END, 'A line of text.')

# create a canvas
canvas = g.ca(width=500, height=500)
Esempio n. 17
0
from swampy.Gui import *
from Tkinter import *

g = Gui()
g.title('Gui')


class Canvas():
    """ """
    def __init__(self):
        canvas = g.ca(width=500, height=500)


class MakeWindow():
    """ """
    def setup(self):

        self.canvas = g.ca(width=500, height=500, bg='white')

    def add_button(self, text, the_command=None):
        g.bu(text, command=the_command)
        #b.pack()


def test_it():
    print "yeah"

    # def set_option(self, color):
    # 	mb.config(text = option)
    # 	print color
Esempio n. 18
0
from swampy.Gui import *

a = Gui()
a.title('Alberto')


def boton1():
    a.bu(text='Presioname otra vez.', command=boton2)


def boton2():
    a.la(text='Buen trabajo.')


a.bu(text='Presioname.', command=boton1)

a.mainloop()