当前位置: 首页>>代码示例>>Python>>正文


Python Gui.en方法代码示例

本文整理汇总了Python中swampy.Gui.en方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.en方法的具体用法?Python Gui.en怎么用?Python Gui.en使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swampy.Gui的用法示例。


在下文中一共展示了Gui.en方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Hwindow

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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')
开发者ID:allisongpatterson,项目名称:Othello,代码行数:34,代码来源:startup.py

示例2: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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()
开发者ID:sirajmuneer123,项目名称:think-python-solutions,代码行数:26,代码来源:19-3.py

示例3: Vector

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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()
开发者ID:venkateshwaracholan,项目名称:Thinkpython,代码行数:32,代码来源:nineteen_five_vector.py

示例4: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]


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)


win.mainloop()

开发者ID:hgsujay,项目名称:SGPA_py,代码行数:30,代码来源:res.py

示例5: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
        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)
#print text.get(0.0, END)
entry = g.en(text='Type a color')
button_color = g.bu(text='Change color', command=change_color)

g.mainloop()
开发者ID:hacpai,项目名称:reading-lists,代码行数:32,代码来源:gui_demo.py

示例6: make_label

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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()
开发者ID:tangc1986,项目名称:PythonStudy,代码行数:30,代码来源:practise19.py

示例7: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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()

开发者ID:bolducp,项目名称:My-Think-Python-Solutions,代码行数:31,代码来源:19.05.03.py

示例8: launch

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
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:
#.........这里部分代码省略.........
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:103,代码来源:rawmingui.py

示例9:

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import en [as 别名]
    	shared_viewer.remove(access)
    	shared_source.remove(access)
    
#General set-up
g.title('Minumum Deliverable URLSender')

g.row()

g.col()

g.la(text = 'Welcome to musicswAPPer')
g.bu(text = 'Update Data', command = MediaShare.update())  
g.row([0,1], pady = 10)
g.endrow()
g.la(text = 'Share a link!')
friend = g.en(text = 'Who do you want to share with?')
en = g.en(text = 'Insert URL here')
g.bu(text = 'Share', command = MediaShare.print_entry())
label = g.la()

g.row([0,1], pady = 10)
g.endrow()

g.la(text = 'Share History')
share_history = g.sc(width = 500, height = 300)
share_history.canvas.configure(confine = False, scrollregion = (0,0,1000,1000)) 
 
g.endcol() 

g.col()
g.ca(height = 100, width = 50)
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:33,代码来源:rawmingui_w_classes.py


注:本文中的swampy.Gui.en方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。