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


Python Gui.ca方法代码示例

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


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

示例1: Gui

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

示例2: Gui

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

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

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

示例4: testBit

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

def testBit(int_type, offset):
    mask = 1 << offset
    return(int_type & mask)

def toggleBit(int_type, offset):
    mask = 1 << offset
    return(int_type ^ mask)

model = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

g = Gui()
g.title('Font creator')
canvas = g.ca(200, 300, bg='orange')

def redrawCanvas():
    canvas.clear()
    for line in range(0, 16):
        canvas.text([70, 140-18*line], '['+str(line)+']='+str(model[line]))
        for pos in range(0, 8):
            x = 40 - pos * 10
            y = 80 - line * 10
            item = canvas.rectangle([[x, y], [x+10, y+10]], fill='white', outline='black', width=1)
            if testBit(model[line], pos) > 0:
                item.config(fill='black')

def mouseClicked(event):
    cc = canvas.canvas_coords([event.x, event.y])
    line = (-cc.y + 90) / 10
开发者ID:crackoff,项目名称:melt6116-fonts,代码行数:32,代码来源:font-creator.py

示例5: drop

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
        # dx = event.x - self.dragx
        # dy = event.y - self.dragy

        pos = ca.canvas_coords([[self.dragx, self.dragy], [event.x, event.y]])
        print pos
        item = ca.rectangle(pos, fill="red")
        # move the item
        # self.move(dx, dy)

    def drop(self, event):
        """Drops this item."""
        self.config(fill=self.fill)


g = Gui()
ca = g.ca(width=500, height=500, bg="white")

item = ca.rectangle([[-250, -250], [100, 100]], fill="red")

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)
开发者ID:venkateshwaracholan,项目名称:Thinkpython,代码行数:33,代码来源:nineteen_five_vector.py

示例6: Gui

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

示例7: change_color

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
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)
#print text.get(0.0, END)
开发者ID:hacpai,项目名称:reading-lists,代码行数:33,代码来源:gui_demo.py

示例8: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
from swampy.Gui import *
from Tkinter import PhotoImage
import PIL.Image
import PIL.ImageTk

g = Gui()
canvas = g.ca(width=300)
photo = PhotoImage(file='danger.gif')
canvas.image([0,0], image=photo)

g.la(image=photo)
g.bu(image=photo)

image = PIL.Image.open('allen.png')
photo2 = PIL.ImageTk.PhotoImage(image)
g.la(image=photo2)


g.mainloop()
开发者ID:tangc1986,项目名称:PythonStudy,代码行数:21,代码来源:practise19-4.py

示例9: drop

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

示例10: ques_pos

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
    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()
开发者ID:VedantPro,项目名称:Sentiment-Analysis,代码行数:32,代码来源:Project+-+Optimism+Test.py

示例11: set_color

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

# mb is for menubutton
mb = g.mb(text="Choose a color")


def set_color(color):
    ca.itemconfig(item2, fill=color)


# mi is for menuitem
for color in ["red", "green", "blue"]:
开发者ID:Ehsan1981,项目名称:ThinkPython,代码行数:33,代码来源:widget_demo.py

示例12: drop

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
        # save the current drag coordinates
        self.dragx = event.x
        self.dragy = event.y

        # move the item 
        self.move(dx, dy)

    def drop(self, event):
        """Drops this item."""
        self.config(fill=self.fill)


# create the Gui and the Canvas
g = Gui()
ca = g.ca(width=500, height=500, bg='white')

def make_circle(event):
    """Makes a circle item at the location of a button press."""
    pos = ca.canvas_coords([event.x, event.y])
    item = ca.circle(pos, 5, fill='red')
    item = Draggable(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 = Draggable(item)
开发者ID:ANB2,项目名称:ThinkPython,代码行数:31,代码来源:draggable_demo.py

示例13: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import ca [as 别名]
models = []
models.append([0, 60, 66, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 66, 60, 0]) #0
models.append([0, 4, 12, 20, 36, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0]) #1
models.append([0, 60, 66, 129, 129, 1, 1, 2, 4, 8, 16, 32, 64, 128, 255, 0]) #2
models.append([0, 60, 66, 129, 1, 1, 2, 12, 2, 1, 1, 1, 129, 66, 60, 0]) #3
models.append([0, 6, 10, 10, 18, 18, 34, 34, 66, 66, 130, 255, 2, 2, 2, 0]) #4
models.append([0, 254, 128, 128, 128, 128, 188, 194, 1, 1, 1, 129, 129, 66, 60, 0]) #5
models.append([0, 60, 66, 129, 128, 128, 188, 194, 129, 129, 129, 129, 129, 66, 60, 0]) #6
models.append([0, 255, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 0]) #7
models.append([0, 60, 66, 129, 129, 129, 66, 60, 66, 129, 129, 129, 129, 66, 60, 0]) #8
models.append([0, 60, 66, 129, 129, 129, 129, 129, 67, 61, 1, 1, 129, 66, 60, 0]) #9

g = Gui()
g.title('Font testing')
canvas = g.ca(1020, 360, bg='orange')

def drawLineOfModels(y_offset, x_delta, e_size):
    for digit in range(0, 10):
        for line in range(0, 16):
            for pos in range(0, 8):
                x = -380 + digit * x_delta - pos * e_size
                y = y_offset - line * e_size
                item = canvas.rectangle([[x, y], [x+e_size, y+e_size]], fill='orange', outline='black', width=0)
                if testBit(models[digit][line], pos) > 0:
                    item.config(fill='black')

drawLineOfModels(80, 90, 10)
drawLineOfModels(-100, 30, 3)

g.mainloop()
开发者ID:crackoff,项目名称:melt6116-fonts,代码行数:32,代码来源:font-testing.py

示例14: launch

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

示例15:

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

g.col()

g.la(text = 'New Shares from Friends')
new_shared_list = g.sc(width = 500, height = 100)
new_shared_list.canvas.configure(confine = False, scrollregion = (0,0,1000,1000))

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

g.la(text = 'Link Preview')
canvas = g.sc(width = 500, height = 300)
canvas.canvas.configure(confine = False, scrollregion = (0,0,2000, 2000))
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:32,代码来源:rawmingui_w_classes.py


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