當前位置: 首頁>>代碼示例>>Python>>正文


Python Gui類代碼示例

本文整理匯總了Python中Gui的典型用法代碼示例。如果您正苦於以下問題:Python Gui類的具體用法?Python Gui怎麽用?Python Gui使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Gui類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: set_game_path

  def set_game_path(self, path):
    self.game_path = path
    self.gp.folder.setText(path)
    self.games = []
    if os.path.isdir(Gui.resolved_path(path)):
      for dirpath, dirnames, filenames in os.walk(Gui.resolved_path(path)):
#        dirnames[:] = []
        for fname in filenames:
          fpath = os.path.join(dirpath, fname)
          mgamefilename = re.compile('(.+)Vs(.+)\.([0-9]+)$')
          m = mgamefilename.match(fname)
          if m:
            self.games.append(GameFile(fname, m.group(1), m.group(2), int(m.group(3)), fpath))
      if len(self.games):
        self.gp.status.setText("%d games found" % len(self.games))
        self.gp.status.setPalette(Gui.BLUE_TEXT)
      else:
        self.gp.status.setText("No games found in '%s'" % path)
        self.gp.status.setPalette(Gui.RED_TEXT)
    else:
      self.gp.status.setText("No folder '%s'" % path)
      self.gp.status.setPalette(Gui.RED_TEXT)
    self.gs.combo.clear()
    self.gs.combo.addItem('Select a game')
    self.games.sort(key=attrgetter('sort_key'))
    for g in self.games:
      self.gs.combo.addItem(str(g))
    self.gp.next.setEnabled(len(self.games) > 0)
    self.gs.next.setEnabled(False)
開發者ID:zsimic,項目名稱:TopCoderAnts,代碼行數:29,代碼來源:AntsViewer.py

示例2: __init__

class Game:
    def __init__(self, mx=10, my=10):
        self.board = Board(mx, my)
        self.gui = Gui(mx, my)
        self.last = sdl2.SDLK_UP
        self.dir = {
            sdl2.SDLK_UP: [-1, 0],
            sdl2.SDLK_DOWN: [1, 0],
            sdl2.SDLK_LEFT: [0, -1],
            sdl2.SDLK_RIGHT: [0, 1],
            }

    def start(self):
        run = True
        self.board.init_board()
        while run:
            for e in sdl2.ext.get_events():
                if e.type == sdl2.SDL_QUIT:
                    exit()
                if e.type == sdl2.SDL_KEYDOWN:
                    k = e.key.keysym.sym
                    if k in self.dir.keys() and self.last != k:
                        self.last = self.check_key(k)
                    if k == sdl2.SDLK_ESCAPE:
                        self.quit()
            run = self.move(self.dir[self.last])
            self.gui.aff(self.board.get_map())
            sdl2.SDL_Delay(200)
        sdl2.ext.quit()
        return 0

    def check_key(self, k):
        l = self.dir[self.last]
        n = self.dir[k]
        return self.last if n[0] == l[0] or n[1] == l[1] else k

    def move(self, d):
        h = self.board.get_head()
        n = (h[0] + d[0], h[1] + d[1])
        self.board.set_head(n[0], n[1])
        if self.board.body.is_body(n):
            return False
        if self.board.apple.is_apple(n):
            self.board.body.rise(d)
            self.board.apple.set_apple(self.board.get_map())
        elif self.board.cherry.is_cherry(self.board.get_map(), n):
            self.board.body.rise(d)
            self.board.cherry.set_cherry(self.board.get_map())
        else:
            self.board.body.move(d)
        self.board.update_board()
        ret = self.board.is_wall(n)
        return ret

    def aff(self):
        self.gui.draw(self.board)

    def quit(self):
        exit()
開發者ID:djavrell,項目名稱:snake,代碼行數:59,代碼來源:Game.py

示例3: test_options

    def test_options(self):
        d = dict(a=1, b=2, c=3)
        res = Gui.pop_options(d, ['b'])
        self.assertEquals(len(res), 1)
        self.assertEquals(len(d), 2)

        res = Gui.get_options(d, ['a', 'c'])
        self.assertEquals(len(res), 2)
        self.assertEquals(len(d), 2)
        
        res = Gui.remove_options(d, ['c'])
        self.assertEquals(len(d), 1)

        d = dict(side=1, column=2, other=3)
        options, packopts, gridopts = Gui.split_options(d)
        self.assertEquals(len(options), 1)
        self.assertEquals(len(packopts), 1)
        self.assertEquals(len(gridopts), 1)

        Gui.override(d, side=2)
        self.assertEquals(d['side'], 2)
 
        Gui.underride(d, column=3, fill=4)
        self.assertEquals(d['column'], 2)
        self.assertEquals(d['fill'], 4)
開發者ID:jfparis,項目名稱:swampy,代碼行數:25,代碼來源:Gui_test.py

示例4: main

def main():
    gui = Gui()

    rawData = readDataset(dataPath)
    data = parseData(rawData)

    gui.drawData(data)

    training, heldout, test = divideData(data)

    rawdata = unlableData(heldout)

    for sample in heldout:
        classification = classify(training, sample)
        print(sample, classification)

    gui.getMouse()
開發者ID:AlejandroSalgadoG,項目名稱:MachineLearning,代碼行數:17,代碼來源:Main.py

示例5: on_browse_folder

 def on_browse_folder(self):
   dialog = QtGui.QFileDialog()
   dialog.setFileMode(QtGui.QFileDialog.Directory)
   dialog.setOption(QtGui.QFileDialog.ShowDirsOnly, True)
   path = dialog.getExistingDirectory(self, 'Directory', Gui.resolved_path(self.default_game_path))
   if path:
     self.set_game_path(path)
     self.main_window.board_view.setFocus()
開發者ID:zsimic,項目名稱:TopCoderAnts,代碼行數:8,代碼來源:AntsViewer.py

示例6: test_bbox

    def test_bbox(self):
        bbox = Gui.BBox([[100, 200], [300, 500]])
        self.assertEquals(bbox.left, 100)
        self.assertEquals(bbox.right, 300)
        self.assertEquals(bbox.top, 200)
        self.assertEquals(bbox.bottom, 500)

        self.assertEquals(bbox.width(), 200)
        self.assertEquals(bbox.height(), 300)

        # TODO: upperleft, lowerright, midright, midleft, center, union

        t = bbox.flatten()
        self.assertEquals(t[0], 100)

        pairs = [pair for pair in Gui.pairiter(t)]
        self.assertEquals(len(pairs), 2)

        seq = Gui.flatten(pairs)
        self.assertEquals(len(seq), 4)
開發者ID:jfparis,項目名稱:swampy,代碼行數:20,代碼來源:Gui_test.py

示例7: display

def display():
	def display_QR():
		qr_bitstring = polynomials.QRbitstring(entry.get().upper())
		i = 0
		for i in range(8):
			canvas = mygui.ca(width=300, height=300)
			canvas.config(bg='white')
			g = Mask(i, qr_bitstring)
			g.drawSquares(canvas)
	

	g = Mask(0, qr_bitstring)

	mygui = Gui()
	mygui.title('QR Encoder')
	label = mygui.la(text='Enter the text to encode here:')
	entry = mygui.en()
	button = mygui.bu(text='Make QR Code', command=display_QR)
	mygui.gr(cols=4)
	mygui.mainloop()
開發者ID:JNazare,項目名稱:QR_Encoder,代碼行數:20,代碼來源:QR_with_classes.py

示例8: on_init

    def on_init(self):
        pygame.init()
        self._running = True

        #instantinate gui
        self.g = Gui()

        #instantinate player
        self.p = []
        for i in range(2):
            self.p.append(Player(i))

        self.turn = 0
開發者ID:1uk,項目名稱:3tsqd,代碼行數:13,代碼來源:Control.py

示例9: instructions

def instructions():     # Display Instructions in a new window
    i = Gui()
    i.title ("Instructions")
    text = i.te (height = 42, width = 150, fg = 'darkblue')
    text.insert (END, "                                               ************************************\n")
    text.insert (END, "                                               ****   Black Jack Instructions  ****\n")
    text.insert (END, "                                               ************************************\n\n")
    text.insert (END, "Objective: The objective of the game is beat the dealer. In order to win, you must have the most points\n without going over 21\n\n")
    text.insert (END, "Terms:\n")
    text.insert (END, "         Hit - Get dealt another card\n")
    text.insert (END, "         Stay - Stop with the amount of cards you have\n")
    text.insert (END, "         Bust - To go over 21\n")
    text.insert (END, "\n\n")
    text.insert (END, "First thing you do is place a bet. The minimum accepted is $5. The maximum is limited to how much $ you\n have.\n")
    text.insert (END, "You and the dealer are then given two cards each. You can draw cards with the 'Hit me!' button. If you\n bust you cannot draw more cards.\n")
    text.insert (END, "When you are happy with your cards press the 'Stay!' button. Once this happens it's the dealers turn.\n")
    text.insert (END, "\n\n")
    text.insert (END, "The Rules:\n")
    text.insert (END, "         Whoever is closest to 21 with going over wins.\n")
    text.insert (END, "         If you both have the same amount, the dealer wins.\n")
    text.insert (END, "         If you bust and the dealer doesn't you lose.\n")
    text.insert (END, "         If the dealer busts and you don't, you win.\n")
    text.insert (END, "         If both you and the dealer bust, you win\n")
    text.insert (END, "\n\n")
    text.insert (END, "       Cards Values:")
    text.insert (END, "           2 -> 2 pts\n")
    text.insert (END, "           3 -> 3 pts\n")
    text.insert (END, "           4 -> 4 pts\n")
    text.insert (END, "           5 -> 5 pts\n")
    text.insert (END, "           6 -> 6 pts\n")
    text.insert (END, "           7 -> 7 pts\n")
    text.insert (END, "           8 -> 8 pts\n")
    text.insert (END, "           9 -> 9 pts\n")
    text.insert (END, "          10 -> 10 pts\n")
    text.insert (END, "        Jack -> 10 pts\n")
    text.insert (END, "       Queen -> 10 pts\n")
    text.insert (END, "        King -> 10 pts\n")
    text.insert (END, "         Ace -> 1 pt or 11 pts\n")
    text.insert (END, "\n\n")
開發者ID:Couragyn,項目名稱:BlackJack,代碼行數:39,代碼來源:Working+Blackjack.py

示例10: make_gui

 def make_gui(self):
     # The Player Menu
     temp_text = "Insert Text here"
     self.player_menu = Gui(self.menu_imgs[0], self.size, 1.5)
     self.player_menu.make_dynamic_text((155, 130), str(self.player.level), (255, 0, 0))
     self.player_menu.make_dynamic_text((300, 70), self.player.name, (0,0,0))
     self.player_menu.make_dynamic_text((450, 150), self.player.title, (0,0,0), 30)
     self.player_menu.make_dynamic_text((64, 440), temp_text, (0,0,0), 20)
     self.player_menu.make_dynamic_text((300, 500), temp_text, (0,0,0), 20)
     self.player_menu.make_button("exit", (50, 30), (1300, 51), "Exit")
     self.p_menu = [0.0, False]
     # HUD Powers buttons
     self.powers_gui = Gui(self.menu_imgs[2], self.size, 12)
     self.powers_gui.new_rect.topleft = ((self.size[0] / 22),(self.size[1] / 20 * 18))
     self.powers_gui.make_dynamic_text((18, 22), "1", (255, 0, 0))
     self.powers_gui.make_dynamic_text((78, 22), "2", (255, 0, 0))
     self.powers_gui.make_dynamic_text((138, 22), "3", (255, 0, 0))
     self.powers_gui.make_dynamic_text((198, 22), "4", (255, 0, 0))
     self.powers_gui.make_dynamic_text((258, 22), "5", (255, 0, 0))
     self.powers_gui.make_dynamic_text((318, 22), "6", (255, 0, 0))
     self.powers_gui.make_dynamic_text((378, 22), "7", (255, 0, 0))
     self.powers_gui.make_dynamic_text((438, 22), "8", (255, 0, 0))
     # Setting up the Mouse over
     self.mouseover = MouseOver(self.menu_imgs[-1])
開發者ID:Exodus111,項目名稱:Infinite-Adventure,代碼行數:24,代碼來源:Game.py

示例11: run

	def run(self):
		self.g=Gui()
		self.g.title('Control Panel')

		#charge
		self.chgla=self.g.la(text='Charge')
		self.g.gr(cols=3)
		minus=self.g.bu(text='-', command=Callable(self.addC, -1))
		self.chg=self.g.en()
		plus=self.g.bu(text='+', command=Callable(self.addC, 1))
		self.g.endgr()

		#position
		self.pos=self.g.la(text='Position')
		self.g.gr(cols=3)
		xla=self.g.la(text='x')
		yla=self.g.la(text='y')
		zla=self.g.la(text='z')
		self.x=self.g.en(text='')
		self.y=self.g.en(text='')
		self.z=self.g.en(text='')
		self.g.endgr()
		#menu
		self.men=self.g.mb(text='Change/ Add Charge')
		hi=self.g.mi(self.men, text='Add point charge', command=Callable(self.addPoint))
		self.g.mi(self.men, text='Add line charge', command=Callable(self.addLine))
		self.g.mi(self.men, text='Find voltage at point', command=self.findVolt)

		
		#add
		self.g.row([1,1])
		self.add=self.g.bu(text='Add')
		self.rem=self.g.bu(text='Delete', command=self.remove)
		self.g.endrow()
		#self.g.bu(text='Quit', command=self.end)
		
		self.disp=self.g.mb(text='Voltage Field')
		self.g.mi(self.disp, text='Voltage Field', command=self.showv)
		self.g.mi(self.disp, text='Electric Field', command=self.showe)
		#ans
		self.ans=self.g.la(text='')

		
		self.field.start()
		for chrg in self.field.charges:
			chrg.makeMi()
		self.g.mainloop()
開發者ID:berit,項目名稱:Project-E-and-M,代碼行數:47,代碼來源:control.py

示例12: make_label

from Gui import *

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

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

button = g.bu(text = 'Press ME.')

label = g.la(text = 'LABEL')

button2 = g.bu(text = 'XYZ', command = make_label)

g.mainloop()
開發者ID:flake123p,項目名稱:ProjectH,代碼行數:15,代碼來源:test.py

示例13: __init__

 def __init__(self):
     self.server = xmlrpclib.ServerProxy('http://localhost:8006')
     self.gui = Gui(self)
     self.currentProject = None
開發者ID:udovisdevoh,項目名稱:superzebre,代碼行數:4,代碼來源:Client.py

示例14: insert

def insert(obj):
	cal_in.insert(END,obj)

def delete(p):
	cal_in.delete(p)
	print p,len(cal_in.get())-1,cal_in.get()

from Gui import *

cal=Gui()
cal.title('Calculator')

cal_in = cal.en(width=35)

cal.row()
cal.gr(cols=6)

seven = cal.bu(text='7',command = Callable(insert,'7'))
eight = cal.bu(text='8',command = Callable(insert,'8'))
nine = cal.bu(text='9',command = Callable(insert,'9'))
div = cal.bu(text='/',command = Callable(insert,'/'))

#bspace = cal.bu(text='Del',command = Callable(delete,0))
bspace = cal.bu(text='Del',command = Callable(delete,len(cal_in.get())-1))

clr = cal.bu(text='Clr',command = Callable(delete,'7'))

four = cal.bu(text='4',command = Callable(insert,'4'))
five = cal.bu(text='5',command = Callable(insert,'5'))
six = cal.bu(text='6',command = Callable(insert,'6'))
mul = cal.bu(text='*',command = Callable(insert,'*'))
開發者ID:binoytv9,項目名稱:Think-Python-by-Allen-B-Downey--Exercises,代碼行數:31,代碼來源:cal.py

示例15: main

def main():
    gui = Gui()

    generateGhost()
    iniProbs = getInitialDist()
    particles = distributeParticles(particleNum, iniProbs)
    probs = getProbs(particles)

    while True:
        gui.drawProb(probs)
        pos = gui.getMouse()

        if pos[1] > numRow-1:
            if pos[0] >= numRow/2:
                gui.setBlackColors()
                moveGhost()
                particles = moveParticles(particles)
                probs = getProbs(particles)
            else:
                gui.drawEndBtn("blue")
                pos = gui.getMouse()
                result = isGhostThere(pos)
                gui.drawResult(pos, result) 
                revealGhost()
                break
        else:
            color = useSensor(pos)
            gui.drawSensorReading(pos, color)
            condProbs = getNewPosDist(pos, color, probs)

            weights = weightParticles(particles, condProbs)
            normWeights = normalize(weights)
            particles = redistributeParticles(particles, normWeights)
            probs = getProbs(particles)

    gui.getMouse()
開發者ID:AlejandroSalgadoG,項目名稱:MachineLearning,代碼行數:36,代碼來源:Main.py


注:本文中的Gui類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。