示例#1
0
class Hwindow():
	"""Creates host/join menu."""
	def __init__(self):
		self.h = Gui() # make h window
		self.h.title('Othello!')
		self.h.la(text='Game Name (no spaces)')
		self.entryField = self.h.en()
		self.h.gr(cols=2)
		hostButton = self.h.bu(text='Host Game', command=self.host)
		joinButton = self.h.bu(text='Join Game',command=self.join)
		self.h.mainloop()

	def host(self):
		"""Creates a game w/ 2 players and 2 computers."""
		name = self.entryField.get()
		data = {
				'gameName': name
		}

		req = urllib2.Request('http://othello.herokuapp.com/createGame')
		req.add_header('Content-Type', 'application/json')

		response = urllib2.urlopen(req, json.dumps(data))
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' black')

	def join(self):
		"""Joins an existing game w/ 2 players and 2 computers."""

		name = self.entryField.get()
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' white')
示例#2
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()
示例#3
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()
示例#4
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()
示例#5
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()
示例#6
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()
示例#7
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()
示例#8
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()
示例#9
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()
示例#10
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()
示例#11
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()
示例#12
0
class Gwindow(): 
	"""Creates local/internet menu."""
	def __init__(self):
		self.g = Gui() # make g window
		self.g.title('Othello!')
		self.g.gr(cols=2)
		localButton = self.g.bu(text='Local Game', command=self.local)
		internetButton = self.g.bu(text='Internet Game', command=self.internet)
		self.g.mainloop()

	def local(self):
		"""Creates a game w/ 2 players on 1 computer."""
		self.g.destroy() # close g window
		os.system('python board_piece_final_tweaked.py') # start local game

	def internet(self):
		"""Leads to next menu."""
		self.g.destroy() # close g window
		Hwindow()
from swampy.Gui import *

g = Gui()
g.title('19-2.py')

def make_create():
	item = canvas.circle([0,0], 100, fill = 'green')
def make_change():
	i = item.config(fill = 'red', outline = 'orange', width = 10)

canvas = g.ca(width = 500, height = 600)
b1 = g.bu(text = 'Press Button', command = make_create)
b2 = g.bu(text = 'Press To change', comman = make_change)

g.mainloop()
from swampy.Gui import *

g = Gui()
g.title('19-3.py')
canvas = g.ca(width = 500, height = 600, bg = 'white')
circle = None

def make_circle():
	circle = canvas.circle([0,0], 100)
def make_change():
	if circle == None:
		return
	color = entry.get()
	try:
		circle.config(fill = color)
	except TclError, message:
		print message


b1 = g.bu(text = 'Create Circle', command = make_circle)
entry = g.en()
b2 = g.bu(text = 'Press to Config', command= make_change)

g.mainloop()
示例#15
0
from swampy.Gui import *

g = Gui()
g.title('Button demo gui')

#tao ra 1 canvas

canvas = g.ca(width=250, height=250)
canvas.config(bg='white')


def draw_circle_in_canvas():
    #cai tien ve hong tam
    item = canvas.circle([0, 0], 100, fill='red')
    item.config(fill='yellow', outline='red', width=15)
    item1 = canvas.circle([0, 0], 70, fill='red')
    item1.config(fill='yellow', outline='red', width=15)
    item2 = canvas.circle([0, 0], 40, fill='red')
    item2.config(fill='yellow', outline='red', width=15)
    item3 = canvas.circle([0, 0], 10, fill='red')
    item3.config(fill='yellow', outline='red', width=15)


button = g.bu(text='First button', command=draw_circle_in_canvas)

g.mainloop()
示例#16
0

def callback1():
    """called when the user presses 'Create circle' """
    global circle
    circle = canvas.circle([0, 0], 100)


def callback2():
    """called when the user presses 'Change color' """

    # if the circle hasn't been created yet, do nothing
    if circle == None:
        return

    # get the text from the entry and try to change the circle's color
    color = entry.get()
    try:
        circle.config(fill=color)
    except TclError, message:
        # probably an unknown color name
        print message


# create the widgets
g.bu(text="Create circle", command=callback1)
entry = g.en()
g.bu(text="Change color", command=callback2)

g.mainloop()
示例#17
0
from swampy.Gui import *

g = Gui()
g.title = "Gui"


def make_circle():
    canvas.circle([0, 0], 55, fill="orange", outline="white", width=3)


canvas = g.ca(500, 500, bg="black")

g.bu(text="make me a circle", command=make_circle)

g.mainloop()
示例#18
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)
示例#19
0
# en is for entry
en = g.en()
en.insert(END, 'This is an entry widget.')

la2 = g.la(text='')


def press_me():
    """this callback gets invoked when the user presses the button"""
    text = en.get()
    la2.configure(text=text)


# bu is for button
bu = g.bu(text='Press me', command=press_me)

# end of the first frame
g.endcol()

# FRAME 2

g.col()

# ca is for canvas
ca = g.ca(width=200, height=200)

item1 = ca.circle([0, 0], 70, 'red')
item2 = ca.rectangle([[0, 0], [60, 60]], 'blue')
item3 = ca.text([0, 0], 'This is a canvas.', 'white')
示例#20
0
"""
Write a program that creates a Canvas and a Button. When the user presses the Button, it should draw a circle on the canvas.
"""

from swampy.Gui import *

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

canvas = g.ca(width=500, height=500)
canvas.config(bg='blue')


def draw_circle():
    global canvas
    canvas.circle([0, 0], 100, fill='red')


g.bu(text='Press me', command=draw_circle)

g.mainloop()
示例#21
0

def callback1():
    """called when the user presses 'Create circle' """
    global circle
    circle = canvas.circle([0, 0], 100)


def callback2():
    """called when the user presses 'Change color' """

    # if the circle hasn't been created yet, do nothing
    if circle is None:
        return

    # get the text from the entry and try to change the circle's color
    color = entry.get()
    try:
        circle.config(fill=color)
    except TclError as message:
        # probably an unknown color name
        print message


# create the widgets
g.bu(text='Create circle', command=callback1)
entry = g.en()
g.bu(text='Change color', command=callback2)

g.mainloop()
示例#22
0
from swampy.Gui import *
g = Gui()


def draw_circle(fill_color='black'):
    canvas = g.ca(width=300, height=300, bg='white')
    c = canvas.circle([0, 0], 100, outline='black')
    c.config(fill=fill_color)


def read():
    color = ent.get()
    print color
    colors = [
        'white', 'black', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta'
    ]
    for c in colors:
        print c
        if color == c:
            draw_circle(color)
            return
    print "no color match"


g.bu(text='Draw circle', command=draw_circle)
g.title('draw cicle')
ent = g.en()
g.bu(text='second button', command=read)
g.mainloop()
示例#23
0
canvas = g.ca(width=500, height=500, bg='white')
circle = None

def callback1():
    """called when the user presses 'Create circle' """
    global circle
    circle = canvas.circle([0,0], 100)

def callback2():
    """called when the user presses 'Change color' """

    # if the circle hasn't been created yet, do nothing
    if circle == None:
        return

    # get the text from the entry and try to change the circle's color
    color = entry.get()
    try:
        circle.config(fill=color)
    except TclError, message:
        # probably an unknown color name
        print message
        

# create the widgets
g.bu(text='Create circle', command=callback1)
entry = g.en()
g.bu(text='Change color', command=callback2)

g.mainloop()

from swampy.Gui import *

colors=['white', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta']
cir=None
g = Gui()
g.title('Exercise 3')
def cb1():
    cir = canvas.circle([0,0], 100, fill='black', outline='white')
    global cir
def cb2():
    if cir == None:
        return
    color = entry.get()
    if color in colors:
        cir.config(outline=color)
    else:
        raise ValueError
    

button = g.bu(text='Draw Circle', command=cb1)
entry = g.en(text='white')
button_change_color = g.bu(text='Change', command=cb2)
canvas = g.ca(width=500, height=500)
canvas.config(bg='black')

g.mainloop()
示例#25
0
from swampy.Gui import *
#from Gui import * #这句话不要,第一句话就可以了

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

button = g.bu(text='lOVE Mi')
label = g.la(text='it is the label do sth')


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


button2 = g.bu(text='no,press me', command=make_label)  #create a button

canvas = g.ca(width=500, height=500)
canvas.config(bg='red')
item = canvas.circle([0, 0], 100, fill='black')
item.config(fill='yellow', outline='orange', width=10)
canvas.rectangle([[0, 0], [200, 100]], fill='red', outline='orange',
                 width=10)  #draw a rectangle
canvas.oval([[0, 0], [200, 100]], outline='pink', width='20')  #draw an oval
canvas.line([[0, 100], [100, 200]], width=20)  #draw a lines

g.mainloop()
示例#26
0
#coding:utf-8

from swampy.Gui import *

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

canvas = g.ca(width=500, height=500)
canvas.config(bg='blue')


def draw_circle():
    canvas.circle([0, 0], 100, fill='red', outline='green')


g.bu(text='Create a circle', command=draw_circle)

g.mainloop()
from swampy.Gui import *

g = Gui()
g.title('19-2.py')

def make_create():
	item = canvas.circle([0,0], 100, fill = 'green')

canvas = g.ca(width = 500, height = 600)
b1 = g.bu(text = 'Press Button', command = make_create)

g.mainloop()
示例#28
0
from swampy.Gui import *


def call2():
    g.la(text='GUI PROGRAMMING')


def call1():
    g.bu(text='press here again', command=call2)


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

button1 = g.bu(text='press here', command=call1)
g.mainloop()
def main():
    client = MongoClient()
    db = client.test_database

    users = db.users
    users.remove()
    print users
    users.insert({'user':'******', 'password':'******'})
    for thing in users.find():
        print thing

    def newusergui():
        def close():
            signupgui.quit()
            
        def newuser():
            for user in users.find():
                for info in user:
                    print info
                    print user[info]
                    if user[info]==newusername.get():
                        print 'already in use'
                        label.config(text="That username is already in use.")
                        return
            if newpassword.get()==repeatnewpassword.get():
                print 'running this loop'
                users.insert({'user':newusername.get(), 'password': newpassword.get()})
                print users
                label.config(text="Thank you for signing up!")
                close()
                launch()
                return True
            else:
                label.config(text="Your passwords don't match! Please try again")
            
        usernamelabel=signupgui.la(text='Username:'******'Password:'******'*')
        repeatpasswordlabel=signupgui.la(text='Re-enter Password')
        repeatnewpassword=signupgui.en(show='*')
        button=signupgui.bu(text="Let's get started!",command=newuser)
        label=signupgui.la()
        

    def logingui():
    
        def close():
            for user in users.find():
                for info in user:
                    if password.get()==user[info]:
                        label.config(text= "You are now logged in!")
                        signupgui.quit()
                        launch()
                        return True 
                    else:
                        label.config(text= "We do not recognize your username or password, please try again.")
                    
        usernamelabel=signupgui.la(text = "MusicSwAPPer Username:  "******"MusicSwAPPer Password:  "******"Let's get started!",command=close)
        label=signupgui.la()

            
    signupgui=Gui()
    signupgui.title('MusicSwAPPer Sign Up')
    signuporlogin = signupgui.la(text = 'Please Sign-In or Sign-Up!')
    signupgui.row()
    login = signupgui.bu(text = 'Sign in', command=logingui)
    sign = signupgui.bu(text = 'Sign up', command=newusergui)
    signupgui.endrow()

    signupgui.mainloop()
示例#30
0
def main():
    """
    Launches login system everytime the script is run, users have the option of signing in, or signing up if they have not already established an account and accout information. Upon login/signup, the main application is launched
    """
    
    def newusergui():
        """
        for anyone who needs to register, this adds them to the database system
        """
        def newuser():
            global username
            for user in users.find():
                for info in user:
                    if user[info]==newusername.get():
                        label.config(text="That username is already in use.")
                        return
            if newpassword.get()==repeatnewpassword.get():
                users.insert({'user':newusername.get(), 'password': newpassword.get()})
                db.add_user(newusername.get(), newpassword.get())
                label.config(text="Thank you for signing up!")
                username = newusername.get()
                launch()
            else:
                label.config(text="Your passwords don't match! Please try again")
            
        usernamelabel=g.la(text='Username:'******'Password:'******'*')
        repeatpasswordlabel=g.la(text='Re-enter Password')
        repeatnewpassword=g.en(show='*')
        button=g.bu(text="Let's get started!",command=newuser)
        label=g.la()
        

    def logingui():
        """
        this launches the general sign-in gui for those who have registered
        """
        
        def close():
            global username
            for user in users.find():
                    if password.get()==user['password'] and usernameentry.get() == user['user']:
                        label.config(text= "You are now logged in!")
                        username = usernameentry.get()
                        g.quit()
                        launch()
                        return True 
                    else:
                        label.config(text= "We do not recognize your username or password, please try again.")
                    
        usernamelabel=g.la(text = "MusicSwAPPer Username:  "******"MusicSwAPPer Password:  "******"Let's get started!",command=close)
        label=g.la()
               
    g=Gui()
    g.title('Launch MusicSwAPPer')
    signuporlogin = g.la(text = 'Please Sign-In or Sign-Up!')
    g.row()
    login = g.bu(text = 'Sign in', command=logingui)
    sign = g.bu(text = 'Sign up', command=newusergui)
    g.endrow()

    g.mainloop()
示例#31
0
from swampy.Gui import *

g = Gui()
g.title('19-3.py')
canvas = g.ca(width=500, height=600, bg='white')
circle = None


def make_circle():
    circle = canvas.circle([0, 0], 100)


def make_change():
    if circle == None:
        return
    color = entry.get()
    try:
        circle.config(fill=color)
    except TclError, message:
        print message


b1 = g.bu(text='Create Circle', command=make_circle)
entry = g.en()
b2 = g.bu(text='Press to Config', command=make_change)

g.mainloop()
示例#32
0
from swampy.Gui import *

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


def make_circle():
    item = canvas.circle([0, 0], 100, fill='red')


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

g.bu(text='Circle maker', command=make_circle)

g.mainloop()
示例#33
0
def launch():
    """
    launches the 'real' gui system, the one we interact with
    """
    #names new databases that we will use now that the application is launched
    share_hist = db.share_hist
    display = db.display
    point_total = db.point_total
    shared_source = db.shared_source
    shared_viewer = db.shared_viewer

    #clears the databases upon running script
    #IMPORTANT: leave the shared_viewer.remove()
    shared_viewer.remove()

    

    def initialize():
        """
        upon running the script, gets data from the database and updates the gui displays
        """

        global count
        global share_count
        global username
        try:
            for thing in point_total.distinct(username):
                amount = thing
            points.config(text = str(amount))
        except:
            point_total.insert({username:10})
            for thing in point_total.distinct(username):
                amount = thing
            points.config(text = str(amount))
        for thing in display.distinct(username):
            share_history.canvas.text([0,count], text = thing['friend'] + ' ' + thing['share'] + ' ' + str(thing['date']))
            count -= 12
        for thing in shared_viewer.distinct(username):
            link = new_shared_list.canvas.text([0,share_count], text = str(thing[username]['link']), activefill = 'blue')
            link.bind('<Double-1>', onObjectClick)
            share_count -= 12
            

    def update():
        """
        when the update button is pushed, this looks at the database, and will print things not already in the display, as well as log displayed data (meaning that if the gui closes before update is pressed, the data is still saved, and will be displayed the next time update will be pressed)
        """
        global count
        global username
        for log in share_hist.find():
            if log not in display.find():
                display.insert(log)
                share_history.canvas.text([0,count], text = log[username]['friend'] + ' ' + log[username]['share'] + ' ' + str(log[username]['date']))
                count -= 12
        get_new_shares()
        
       
    def print_entry():
        """
        Allows shares to be made, will check to make sure nothing is a repeat, will log the data.  Interactive with the user.
        """
        global count
        global username
        res = []
        text = en.get()
        connection = friend.get()
        for user in users.find():
            res.append(user['user'])
        if connection not in res:
            label.config(text = 'Sorry, user not in our records')
            return 
        follower = ' was shared with '
        message = text + follower + connection + '!'
        for thing in point_total.distinct(username):
            existing = thing
            point_total.update({username: existing}, {'$inc': {username:(-1)}})
            points.config(text = str(existing-1))
        if  count == 1:
            t = datetime.datetime.now()
            if t.minute < 10:
                minute = '0'+str(t.minute)
            else:
                minute = str(t.minute)
            timestamp = str(t.month) + '/' + str(t.day) +'/' + str(t.year) + ',' +str(t.hour) + ':' + minute
            share_hist.insert({username:{'friend':connection,'share':text, 'date': timestamp}})
            shared_source.insert({connection:{'link': text, 'friend':username}})
            label.config(text = message)
            count -= 12
        else:
            instance_count = 0
            for instance in share_hist.distinct(username):
                if text == instance['share'] and connection == instance['friend']:
                    label.config(text = 'That is a repeat!')
                    return
                instance_count += 1
            if instance_count == len(share_hist.distinct(username)):
                t = datetime.datetime.now()
                if t.minute < 10:
                    minute = '0'+str(t.minute)
                else:
                    minute = str(t.minute)
                timestamp = str(t.month) + '/' + str(t.day) +'/' + str(t.year) + ',' +str(t.hour) + ':' + minute
                share_hist.insert({username:{'friend':connection,'share':text, 'date': timestamp}})
                shared_source.insert({connection:{'link': text, 'friend':username}})
                label.config(text = message)


    def url_display(url):
        """
        downloads a youtube video into a file, then plays that file within the gui space
        url - raw string url from gui input
        """
        myfile="playingvid.mp4"
        try:
	        os.remove(myfile)
        except OSError:
	        k=2

        os.system('youtube-dl -o playingvid.mp4 %s'%url)
        
        gobject.threads_init()
        window_id = canvas.winfo_id()

        player = gst.element_factory_make('playbin2', 'player')
        player.set_property('video-sink', None)
        x=os.path.dirname(os.path.realpath(__file__))
        player.set_property('uri', 'file://%s/playingvid.mp4'%(x))
        player.set_state(gst.STATE_PLAYING)

        bus = player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect('sync-message::element', on_sync_message, window_id)

    def on_sync_message(bus, message, window_id):
            if not message.structure is None:
                if message.structure.get_name() == 'prepare-xwindow-id':
                    image_sink = message.src
                    image_sink.set_property('force-aspect-ratio', True)
                    image_sink.set_xwindow_id(window_id)


    def add_link(new_link):
        """
        adds a link to the shared_viewer display 
        """
        return shared_viewer.insert(new_link)

    def get_new_shares():
        """
        will update the recieved, or shared_viewer display
        """
        global share_count
        global username
        for i in shared_source.distinct(username):
            if i['link'] not in shared_viewer.distinct('link'):
                add_link(i)
                link = new_shared_list.canvas.text([0,share_count], text = str(i['link']), activefill = 'blue')
                link.bind('<Double-1>', onObjectClick)
                share_count -= 12

    def onObjectClick(event):
        """
        allows us to double click on a link and show it, as well as remove it from the list of need to view links
        """
        global username
        for thing in point_total.find():
            for key in thing:
                if key == username:
                    existing = thing[username]
                    point_total.update({username: existing}, {'$inc': {username:1}})
                    points.config(text = str(existing + 1))
        index = event.widget.find_closest(event.x, event.y)
        i = shared_viewer.find()
        access = i[index[0] - 1]
        link = access['link']
        url_display(link)
        shared_source.remove({username: {'link':access['link'], 'friend':access['friend']}})


    #General set-up
    pretty = 'light cyan'

    gui = Gui()
    gui.title('MusicswAPPer')


    gui.row()
    gui.la(text = 'Welcome to the swAPP', bg = 'black', fg='cyan', justify = 'left', font = ('Times', 20, 'bold italic'), height = 2, relief = 'groove')
    gui.endrow()
    gui.row(bg=pretty)
    gui.col(bg=pretty)
    gui.bu(text = 'Refresh', fg = 'forest green', font = ('Times', 15, 'bold'), bg=pretty, activeforeground='forest green', activebackground='powder blue', command = update) 
    gui.row([0,1], pady = 10, bg=pretty)
    gui.endrow()
    gui.la(text = 'Share a link', bg = pretty, font = ('Times', 13, 'italic'), anchor = 'left', justify='left')
    friend = gui.en(text = 'Who do you want to share with?', disabledforeground = 'light gray', fg = 'black', font = ('Times', 12))
    en = gui.en(text = 'Insert URL here', font = ('Times', 12))
    gui.bu(text = 'Share', font = ('Times', 15, 'bold'), bg = pretty, fg = 'forest green', activebackground = 'powder blue', activeforeground = 'forest green', command = print_entry)
    label = gui.la(bg=pretty, font=('Times', 11))

    gui.row([0,1], pady = 10, bg=pretty)
    gui.endrow()

    gui.la(text = 'Share history', bg=pretty, font=('Times',13, 'italic'))
    share_history = gui.sc(width = 500, height = 300)
    share_history.canvas.configure(confine = False, scrollregion = (0,0,1000,1000)) 
     
    gui.endcol() 

    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty, bd=0)
    gui.endcol()
    gui.col(bg=pretty)
    gui.ca(height = 10, width = 5, bg=pretty, bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.endcol()
    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty)
    gui.endcol()

    gui.col(bg=pretty)

    gui.la(text = 'New Shares from Friends', bg = pretty, font=('Times', 13, 'italic'))
    new_shared_list = gui.sc(width = 500, height = 100)
    new_shared_list.canvas.configure(confine = False, scrollregion = (0,0,1000,1000))

    gui.row([0,1], pady = 30, bg=pretty)
    gui.endrow()

    gui.la(text = 'Viewer', bg=pretty, font = ('Times', 13, 'italic'))
    canvas = gui.ca(width = 500, height = 300, bg='black')
    canvas.configure(confine = False, scrollregion = (0,0,2000, 2000))

    points = gui.la(bg=pretty)


    gui.endcol()

    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty)
    gui.endcol()

    gui.endrow()
    initialize()
    gui.mainloop()
示例#34
0
from swampy.Gui import *

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


def make_button():
    g.bu(text='Label maker', command=make_label)


def make_label():
    g.la(text='Nice job!')


g.bu(text='Button maker', command=make_button)

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

item = canvas.circle([0, 0], 100, fill='red')
item.config(fill='yellow', outline='orange', width=10)

g.mainloop()
示例#35
0
def change_color():
    if circle == None:
        return 'Create a circle before press button.'
    color = entry.get()
    try:
        circle.config(fill=color)
    except:
        message = 'probaly an unknown color name'
        print message


g = Gui()

g.title('Gui')
button = g.bu(text='Press it', command=callback1)
canvas = g.ca(width=500, height=500)
circle = None
#canvas.config(bg='black')
#item = canvas.rectangle([[0, 0], [200, 200]],
        #fill='white', outline='orange',width=10)

#item = canvas.oval([[0, 0], [200, 100]],
        #fill='white', outline='orange',width=10)
#item = canvas.line([[0, 100], [100, 200], [200, 100]], width=10, fill='white')
#item = canvas.polygon([[0, 100], [100, 200], [200, 100]], width=10, fill='white', outline='orange')
#entry = g.en(text='Default text.')
#print entry.get()
#text = g.te(width=100, height=5)
#text.insert(2.3, 'nother')
#text.delete(0.2, END)
'''
Exercise 2  
Write a program that creates a Canvas and a Button. When the user presses the Button, it should draw a circle on the canvas.
'''
from swampy.Gui import *

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


def cb1():
    item = canvas.circle([0, 0], 100, fill='black', outline='white')


button = g.bu(text='Draw Circle', command=cb1)
canvas = g.ca(width=500, height=500)
canvas.config(bg='black')

g.mainloop()
示例#37
0
文件: res.py 项目: hgsujay/SGPA_py
def res():
            u=entry.get()		#get the entry from the txt field(input USN)
            final_res(u.upper())	#pass the usn into the function



win = Gui()	#initialise a win object
win.title('GPA Analysis')
win.row()
logo1=PIL.open('logo.png')
logo=ImageTk.PhotoImage(logo1)
win.la(image=logo)
win.row([0,0], padx=50)
win.la(text='Analysing 4th sem, ECE results \n of the year 2014')
win.col()
win.bu(text='About the app', command=ab_app)
win.bu(text='About the Developer', command=ab_dev)
win.la(text='Kindly mail your feedback to \n [email protected]')
win.endcol()
win.col([0,3],pady=70,padx=50)
win.la(text='Enter your USN')
entry=win.en(text='1BM12EC129')
win.bu(text='View result analysis', command=res)	#function res is invoked when the bu is clicked
win.endcol()
win.row([0,4], padx=1)
win.col()
bms=PIL.open('bmslogo.png')
bms=ImageTk.PhotoImage(bms)
win.la(image=bms)

g = Gui()
g.title = "Gui"
circle1 = False


def make_circle():
    global circle1
    circle1 = canvas.circle([random.randint(-200, 200), random.randint(-200, 200)], 55, fill="orange", outline="white", width=3)


def change_circle_color():
    if circle1 == False:
        g.la(text="You must make the circle first")
        return
    try:
        color = entry.get()
        circle1.config(fill=str(color))
    except:
        g.la(text="Please enter a valid color")
        return


canvas = g.ca(500, 500, bg="black")
g.bu(text="make me a circle", command=make_circle)
entry = g.en(text="name a color")
g.bu(text="change circle color to entry", command=change_circle_color)


g.mainloop()

vec = Vector(item)
ca.bind("<ButtonPress-1>", vec.select)


def make_circle(event):
    """Makes a circle item at the location of a button press."""
    dx = event.x
    dy = event.y
    pos = ca.canvas_coords([[event.x, event.y], [event.x + 10, event.y + 10]])
    print pos
    item = ca.rectangle(pos, fill="red")
    item = Vector(item)


ca.bind("<ButtonPress-3>", make_circle)


def make_text(event=None):
    """Pressing Return in the Entry makes a text item."""
    text = en.get()
    item = ca.text([0, 0], text)
    item = Vector(item)


g.row([0, 1])
bu = g.bu("Make text item:", make_text)
en = g.en()
en.bind("<Return>", make_text)

g.mainloop()
    presuf=sample(list2, 4)[:]
    r=randint(1,2)
    if r==1:
        ques_pos()
    elif r==2:
        ques_neg()
    
def close(event=NONE):
    if tkMessageBox.askyesno("Quit","Do You Want To Quit???"):
        p.destroy()
    

p=Gui()
p.title('Sentiment Analysis')
p.geometry(newGeometry='700x500')

fr=p.fr()
canint=p.ca(bg='green')
imag=Image.open('pic1.jpg')
imag2=ImageTk.PhotoImage(imag)
canint.image([300,-200],image=imag2)
canint.image=imag2
var=IntVar(0)
var2=IntVar(0)
but1=p.bu('YES',command=start,font=('bold',15), bg='red', fg='white', activebackground='white',activeforeground='red',bd=8).place(x=175,y=370, height=50, width=80)
p.bind('y',start)
but2=p.bu('NO',command=close,font=('bold',15), bg='red', fg='white', activebackground='white',activeforeground='red',bd=8).place(x=450,y=370, height=50, width=80)
item1=canint.create_text(350,140,text="\nWelcome!!!\n Hope You Had A Great Day Till Now.\nIf Not, We Are Gonna Make It Great With This Program!!!\n\n\nSo Shall We Begin???",font=('BOOKMAN OLD STYLE',17,'bold'),justify=CENTER,fill='white')
p.bind('n',close)
p.mainloop()
"""Exercise 2
Write a program that creates a Canvas and a Button. When the user presses the Button,
it should draw a circle on the canvas."""

from swampy.Gui import *

g = Gui()
g.title = "Gui"

def make_circle():
    canvas.circle([0, 0], 55, fill="orange", outline="white", width=3)

canvas = g.ca(500, 500, bg="black")

g.bu(text="make me a circle", command=make_circle)

g.mainloop()

示例#42
0
# en is for entry
en = g.en()
en.insert(END, "This is an entry widget.")

la2 = g.la(text="")


def press_me():
    """this callback gets invoked when the user presses the button"""
    text = en.get()
    la2.configure(text=text)


# bu is for button
bu = g.bu(text="Press me", command=press_me)

# end of the first frame
g.endcol()


# FRAME 2

g.col()

# ca is for canvas
ca = g.ca(width=200, height=200)

item1 = ca.circle([0, 0], 70, "red")
item2 = ca.rectangle([[0, 0], [60, 60]], "blue")
item3 = ca.text([0, 0], "This is a canvas.", "white")
from swampy.Gui import *
import Tkinter
import Image as PIL
import ImageTk

g = Gui()
g.title('Image Viewer')
canvas = g.ca(width = 400, height = 400)
photo = Tkinter.PhotoImage(file = 'danger.gif')
''' PhotoImage reads a file and returns a PhotoImage object that
Tkinter can display '''
canvas.image([0,0], image = photo)
g.la(image = photo)
g.bu(image = photo)
g.mainloop()
示例#44
0
from swampy.Gui import *

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

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

button = g.bu(text='Press me.')
button2 = g.bu(text='No, press me!', command=make_label)
label = g.la(text='Press the buttom.')
canvas = g.ca(width=500, height=500)
canvas.config(bg='white')
item = canvas.circle([0,0], 100, fill='red')
item.config(fill='yellow', outline='orange', width=10)
canvas.rectangle([[0,0], [200,200]],
                 fill='blue',outline='orange',width=10)
canvas.oval([[0,0], [200,100]], outline='orange', width=10)
canvas.line([[0,100], [100,200], [200,100]], width=10)
canvas.polygon([[0,100], [100,200], [200,100]],
               fill='red', outline='orange', width=10)
entry = g.en(text='Default text.')
text = g.te(width=100, height=5)
text.insert(END, 'A line of text.')
text.insert(1.1, 'nother')
text.delete(1.2, END)

g.mainloop()
示例#45
0
from swampy.Gui import *

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

def make_button():
	b2 = g.bu(text = 'Press here too..!!!', command = make_label)

def make_label():
	g.la(text = 'Nice job !')

b1 = g.bu(text = 'Press here', command = make_button)

g.mainloop()
示例#46
0
        self.dragy = event.y

        self.move(dx, dy)

    def drop(self, event):
        self.config(fill=self.fill)


def make_circle(event):
    pos = ca.canvas_coords([event.x, event.y])
    item = ca.circle(pos, 5, fill='white')
    Draggable(item)

def make_text(event=None):
    text = en.get()
    item = ca.text([0,0], text)
    Draggable(item)


g = Gui()
g.title('Draggable Demo')
ca = g.ca(width=500, height=500, bg='black')
ca.bind('<ButtonPress-3>', make_circle)

g.row([1,0])
en = g.en()
bu = g.bu('Make text item:', make_text)
en.bind('<Return>', make_text)

g.mainloop()
        if button:
            make_button(n-1)
        if n == 0:
            return button


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


def print_button():
    global count
    count += 1
    print count,"pressed"
    b = g.bu(text='Press me', command=print_button)
    if(count == 3):
        return
    

def callback1(n):
    print n
    g.bu(text='Now press me.', command=callback2)


def callback2():
    g.la(text='Nice job.')
def a():
    callback1(10)
g.bu(text='Press me.', command=lambda:callback1(10))
g.mainloop()
#!/usr/bin/env python

from swampy.Gui import *

def make_circle():
    circle = canvas.circle([0,0], 100, fill='red')
    entry = g.en(text='Enter Color')
    button2 = g.bu(text='Enter', command=change_color)
    global circle, entry

# handle the exception of changing color on a circle not created by 
# the order of operations, i.e. does not get to the color change until circle is created. 
def change_color():
    color = entry.get()
    colorList = ['white', 'black', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta']
    if color not in colorList:
        print "The color you specified is not valid. Available colors are: "
        for i in colorList:
            print i
    else:
        circle.config(fill=color)

g = Gui()
g.title('Gui')
canvas = g.ca(width=500, height=500)
canvas.config(bg='white')
button1 = g.bu(text="Make Circle", command=make_circle)
g.mainloop()


示例#49
0
'''import urllib

conn = urllib.urlopen('http://thinkpython.com/secret.html')
for line in conn:
print line.strip()'''

from swampy.Gui import *

g = Gui()
g.title('Web Browser')
canvas = g.ca(width=400, height=400)
b1 = g.bu(text="Click to browse", command=make_change)
示例#50
0
#!/usr/bin/env python

from swampy.Gui import *


def make_label():
    g.la(text='Good Job!')


def make_button():
    g.bu(text='Next', command=make_label)


g = Gui()
g.title('Gui')
button1 = g.bu(text="Press Me", command=make_button)
g.mainloop()
示例#51
0
from swampy.Gui import *

g = Gui()
g.title = "Gui"


def make_nicejob_button():
    g.bu(text="I make nicejob label", command=make_nicejob_label)


def make_nicejob_label():
    g.la(text="nice job")


button1 = g.bu(text="first button", command=make_nicejob_button)

g.mainloop()
示例#52
0
from swampy.Gui import *

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

def callback1():
    g.bu(text='Now press me.', command=callback2)

def callback2():
    g.la(text='Nice job.')

g.bu(text='Press me.', command=callback1)

g.mainloop()
示例#53
0
#coding:utf-8

from swampy.Gui import *

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


def create_button():
    g.bu(text='I am the new button. Press me!', command=make_label)


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


button1 = g.bu(text='Please press me.', command=create_button)

button1

g.mainloop()
from swampy.Gui import *
g = Gui()
g.title("Gui")


text = g.te(width=100, height=5)
canvas = g.ca(width=300, height=300)
canvas.config(bg='grey')
circle = None
def change_color():
    global circle
    color = entry.get()
    print color
    if circle == None:
        return
    circle.config(fill=color)

def draw_circle():
    global circle
    circle = canvas.circle([0, 0], 100, fill='red')

g.bu(text='create circle', command=draw_circle)
entry = g.en()
g.bu(text='change color', command=change_color)



g.mainloop()
from swampy.Gui import *
import Tkinter
import Image as PIL
import ImageTk

g = Gui()
g.title('Image Viewer')
canvas = g.ca(width=400, height=400)
photo = Tkinter.PhotoImage(file='danger.gif')
''' PhotoImage reads a file and returns a PhotoImage object that
Tkinter can display '''
canvas.image([0, 0], image=photo)
g.la(image=photo)
g.bu(image=photo)
g.mainloop()
示例#56
0
"""
Write a program that creates a Canvas and a Button. When the user presses the Button, it should draw a circle on the canvas
"""

from swampy.Gui import *

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

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

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


def callback1():
    g.bu(text='Now press me.', command=callback2)


def callback2():
    g.la(text='Nice job.')


g.bu(text='Press me.', command=callback1)

g.mainloop()