Exemplo n.º 1
0
def main():
    cap = cv.VideoCapture(0)
    window = gui.Window()
    aim = window.create_circle((0, 0), 300, fill="#999")
    target = window.create_circle((500, 500), 50, fill="black")

    tracker = kstrack.KerasTracker(FRAME_SHAPE)

    def on_update():
        size = np.array(
            [window.canvas.winfo_width(),
             window.canvas.winfo_height()])

        ret, frame = cap.read()
        #cv.imshow('frame', self.frame)
        #cv.waitKey(1)

        target_pos = target.pos / size
        print('Target pos:', target_pos)
        tracker.add_sample(frame, target_pos)
        tracker.train()

        pos = tracker.predict(np.expand_dims(frame, 0)) * size
        print('pos:', pos)

        aim.pos = pos

        target.pos = np.array([900 + 200 * math.sin(time.time()), 500])

    window.on_update = on_update
    window.start()
Exemplo n.º 2
0
 def test_model_converter(self):
     #create window
     root = Tk()
     root.geometry("800x600")
     self.app = gui.Window(root, "hello world")
     self.app.show_text("hello world")
     root.mainloop()
Exemplo n.º 3
0
 def __init__(self, client: 'Client'):
     self.client: Client = client
     self.window = gui.Window("Game Client Menu", resolution=10)
     # Pages
     PageHome(self.window, self, "home")
     PageGame(self.window, self, "games")
     PageLoadGame(self.window, self, "load_game")
     PageSetting(self.window, self, "settings")
     self.window.show_page("home")
Exemplo n.º 4
0
def main():
    """
    Main Application Method
    ARGS:       None
    RETURNS:    None
    """
    root = Tk()
    app = gui.Window(root)
    root.wm_title("Amazfit Bip Interface")
    root.geometry("360x700")
    root.mainloop()
    image.clean_up()
Exemplo n.º 5
0
def Start():
    #Init variables
    variables.init()

    #Create the window
    variables.window = gui.Window()

    #Get songs
    variables.songs = network.GetSongs()

    #Authenticate
    auth.Authenticator(StartGame)
Exemplo n.º 6
0
    def __init__(self, filepath=DATASET_DEFAUL_FILE_PATH, debug=False):
        self.filepath = filepath
        self.debug = debug

        self.window = gui.Window()
        self.aim = self.window.create_circle((500, 500), 50, 'black')

        self.cap = cv.VideoCapture(0)

        self.frame_buffer = 32  # internal size of dataset (buffer)
        self.frame_index = -1

        self.speed = np.zeros((2, ))
Exemplo n.º 7
0
def main():

    from PyQt4 import QtGui
    import gui

    try:
        app = QtGui.QApplication(sys.argv)
        w = gui.Window()
        w.show()
    except:
        print("Failed to initialize QtGui interface")

    sys.exit(app.exec_())
Exemplo n.º 8
0
    def chatWindow(self, windowtext=None):
        ''' Opens a new chat window
        '''
        global desktopChat
        global move_to_next_chatwin_flag

        move_to_next_chatwin_flag = False  #so that the next window waits for the user to press enter
        # Disable other gui
        gui_buttons.gui_obj.disable_buttons()

        # Stopping the updation thread
        threades.pause_update_thread()

        # Custom Window Style
        win_style = gui.defaultWindowStyle.copy()
        win_style['bg-color'] = (0, 0, 0)

        # Calculating position and size of window from the size of the desktop
        position_win = threades.resize_pos((150.0, 50.0))
        size_win = threades.resize_pos((900, 800))
        #print 'size win is',size_win,'\n'

        # Creating window
        self.chatWin = gui.Window(position=position_win,
                                  size=size_win,
                                  parent=desktopChat,
                                  text='',
                                  style=win_style,
                                  closeable=False,
                                  shadeable=False,
                                  moveable=False)
        self.chatWin.surf.fill((0, 0, 0, 140))
        self.chatWinFlag = True

        #NOTE: This part will be used once we know how to blit buttons on the chat window
        #self.button_skip = gui.Button(position = threades.resize_pos((500.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Skip",style = self.button_style)
        #self.button_next = gui.Button(position = threades.resize_pos((200.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Next >",style = self.button_style)
        #self.button_skip.onClick=self.closeChatWindow
        #self.button_skip.onMouseOver=self.closeChatWindow
        #print self.button_skip.enabled

        #creating label for writing the text
        self.label = gui.Label(position=threades.resize_pos(
            (100.0, 760.0), (900.0, 800.0), self.chatWin.size),
                               size=threades.resize_pos((700.0, 30.0),
                                                        (900.0, 800.0),
                                                        self.chatWin.size),
                               parent=self.chatWin,
                               text=model.text_file.proceed_text[0],
                               style=self.labelStyleCopy)
def main():
    parser = OptionParser()
    parser.add_option("-l", "--list", action="store_true", dest="list", help="List your saved minecraft worlds.")
    parser.add_option("-t", "--token", type="string", dest="token", help="Your sketchfab api token. Can be found on your dashboard.")
    parser.add_option("-w", "--world", type="string", dest="world", help="Name of minecraft world to export.")
    parser.add_option("-d", "--dimension", type="string", dest="dimension", default="0", help="Dimension number to export from world. Default is 0 for the overworld.")
    parser.add_option("-n", "--name", type="string", dest="title", help="Sketchfab model title.")
    parser.add_option("-a", "--area", type="string", dest="area", help="Box x, z limit coordinates of world selection. Format : xmin,xmax,zmin,zmax")
    parser.add_option("-y", "--height", type="string", dest="height", help="y coordinates limit. Format : ymin,ymax")
    (options, args) = parser.parse_args()

    gui_enabled = True

    # if arguments passed, switch to cli
    if not options.list is None or not options.world is None:
        gui_enabled = False

    if gui_enabled is True:
        import gui
        try:
            from PyQt4 import QtGui

            app = QtGui.QApplication(sys.argv)
            w = gui.Window()
            w.show()
            w.setFixedSize(w.size())

            sys.exit(app.exec_())
        except:
            print("Failed to initialize QtGui interface. Switching to cli.")

            # if gui failed to start fallback to cli
            gui_enabled = False

    if gui_enabled is False:
        import cli
        cli.main(options)
Exemplo n.º 10
0
def interface_test():
    pic_path = 'screenshot.png'
    adblib.screenshot(pic_path)

    width, height = get_image_size(pic_path)

    prop = scaled_width / width

    print('width: %f; height: %f; prop: %f' % (width, height, prop))

    w = gui.Window(100, 100, "Hax", debug=True)
    w.load('index.html')

    def on_click(msg):
        #print(msg)
        prop = float(msg['prop'])
        adblib.click(msg['x'] / prop, msg['y'] / prop)

    w.on_gui_event += on_click

    def update():
        done = False
        from multiprocessing import Process
        p = Process(target=lambda: adblib.screenshot(pic_path))
        p.start()

        js_call = 'setPic("%s", %f, %f, %f)' % (pic_path, width, height, prop)
        #print(js_call)
        w.exec_js(js_call)
        done = True
        w.timeout(2000, update)

    update()

    #w.run(update, 1000)
    w.run()
Exemplo n.º 11
0
def controller(strategies,
               grid_size,
               candy_ratio=1.,
               max_iter=None,
               verbose=0,
               gui_active=False,
               game_speed=None):
    # Pygame Init
    pygame.init()

    clock = pygame.time.Clock()
    if gui_active:
        gui_options = gui.Options()
        win = gui.Window(grid_size, 'Multiplayer Snake', gui_options)
        quit_game = False

    # Start Game
    game = Game(grid_size,
                len(strategies),
                candy_ratio=candy_ratio,
                max_iter=max_iter)
    # state = game.startState()
    state = game.start(strategies)
    prev_human_action = None
    game_over = False

    agent_names = [a.name for a in strategies]

    if "human" in agent_names:
        waiting = True
        while waiting:
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    waiting = False
                    break

    i_human = None
    if "human" in agent_names:
        i_human = agent_names.index("human")

    while not ((gui_active and quit_game) or ((not gui_active) and game_over)):
        # Print state
        if verbose > 0:
            state.printGrid(game.grid_size)
        # Get events
        if gui_active:
            events = pygame.event.get()
            if pygame.QUIT in [ev.type for ev in events]:
                quit_game = True
                continue

        # Compute the actions for each player following its strategy (except human)
        actions = game.agentActions()

        # Compute human strategy if necessary
        human_action = None
        if i_human is not None:
            speed = 2. if pygame.K_SPACE in [
                ev.key for ev in events if ev.type == pygame.KEYDOWN
            ] else 1.
            arrow_key = False
            for event in events:
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_LEFT:
                        human_action = move.Move((-1, 0), speed)
                        arrow_key = True
                    if event.key == pygame.K_RIGHT:
                        human_action = move.Move((1, 0), speed)
                        arrow_key = True
                    if event.key == pygame.K_UP:
                        human_action = move.Move((0, -1), speed)
                        arrow_key = True
                    if event.key == pygame.K_DOWN:
                        human_action = move.Move((0, 1), speed)
                        arrow_key = True

            if not arrow_key and prev_human_action is None:
                human_action = move.Move((0, -1), speed)
            elif not arrow_key:
                human_action = prev_human_action

        # Assign human action
        if i_human is not None and i_human in list(actions.keys()):
            actions[i_human] = human_action
            prev_human_action = human_action

        if verbose > 1:
            print(state)
            print(actions)

        # Update the state
        if not game_over:
            state = game.succ(state, actions, copy=False)
        # Pause
        if game_speed:
            clock.tick(game_speed)

        # Check if game over
        game_over = game.isEnd(state)
        # if game_over:
        # win.print_message('GAME OVER')

        # Update gui
        if gui_active:
            win.updateSprites(state)
            win.refresh()

    if verbose > 0:
        state.printGrid(game.grid_size)

    return state
Exemplo n.º 12
0
def main():
    start = g.Window()
Exemplo n.º 13
0
    items = []
    for dato in datos:
        items.append([
            str(dato['tipo_doc']),
            str(dato['nro_doc']), dato['denominacion']
        ])

    listado.items = items


# --- gui2py designer generated code starts ---
with gui.Window(name='buscapadron',
                title=u'Aplicativo Facturaci\xf3n Electr\xf3nica',
                resizable=True,
                height='636px',
                left='181',
                top='52',
                width='794px',
                image=''):
    with gui.Panel(
            label=u'',
            name='panelbusqueda',
            image='',
            sizer_border=5,
            height='500',
            left='8',
            top='6',
            width='633',
    ):

        nTop = '10'
Exemplo n.º 14
0
    def __set_conf(self, c):
        if type(c) != bool:
            raise TypeError("Argument 'c': expected 'bool', got " +
                            str(type(c)))
        with self.__lock:
            self.__lowConfig = c

    lowConfig = property(__get_conf, __set_conf)


print("MAIN: start")

boolContinue = True

data = Data()
data.window = gui.Window(data)

# GUI main routine
while boolContinue:

    startingTime = pygame.time.get_ticks()

    data.window.draw()

    boolTime = True
    while boolTime and data.window.alive:
        if pygame.event.peek():
            e = pygame.event.poll()
            data.window.handle_event(e)
        data.window.handle_flags()
Exemplo n.º 15
0
            yield self._tree_model[key]
            while True:
                wx_item, cookie = tree.GetNextChild(self.wx_item, cookie)
                if not wx_item.IsOk():
                    break
                key = tree.GetPyData(wx_item)
                yield self._tree_model[key]



if __name__ == "__main__":
    import sys
    # basic test until unit_test
    import gui
    app = wx.App(redirect=False)    
    w = gui.Window(title="hello world", name="frmTest", tool_window=False, 
               resizable=True, visible=False, pos=(180, 0))
    tv = TreeView(w, name="treeview", has_buttons=True, default_style=True)

    root = tv.items.add(text="Root")
    child1 = tv.items.add(parent=root, text="Child 1")
    child2 = tv.items.add(parent=root, text="Child 2")
    child3 = tv.items.add(parent=root, text="Child 3")
    child11 = tv.items.add(parent=child1, text="Child 11")
    child11.ensure_visible()
    child2.set_has_children()

    def expand_item(event):
        "lazy evaluation example: virtually add children at runtime"
        if not event.detail.get_children_count():
            for i in range(5):
                it = tv.items.add(parent=event.detail, text="lazy child %s" % i)
Exemplo n.º 16
0
    # record the message (update the UI)
    log(msg)


def log(msg):
    "Append the message to the output text box control"
    ctrl_output.value += msg + "\n"


# --- gui2py designer generated code starts ---

with gui.Window(
        name='mywin',
        title=u'gui2py chat',
        resizable=True,
        height='461px',
        left='168',
        top='79',
        width='400px',
):
    gui.TextBox(name=u'output',
                multiline=True,
                height='403',
                left='8',
                top='10',
                width='379')
    gui.TextBox(name=u'input', height='30', left='11', top='417', width='323')
    gui.Button(
        label=u'\u2192',
        name=u'send',
        left='348',
Exemplo n.º 17
0
def main():
    App = QApplication(sys.argv)
    p1 = gui.Window()
    sys.exit(App.exec_())
Exemplo n.º 18
0
import gui
import game

def execute(*args):
    global games_count
    games_count += 1
    current_game.table = {i:None for i in range(9)}
    current_game.winner = None
    for im in root.images:
        root.canvas.delete(im)
        root.window.update()

games_count = 0
current_game = game.Game(games_count)
root = gui.Window(current_game)
root.window.bind('<Return>',execute)
root.window.update()
root.window.mainloop()
Exemplo n.º 19
0
"""Main script for running camera controlled labeling
Colin Dietrich 2019
"""
import sys
from PyQt5.QtWidgets import QApplication

import config

if sys.argv[1] == 's':
    from camera_capture import CAM
    cam = CAM(cam_id=config.camera_id, description=config.description)
    cam.save_directory = config.stream_dir
    cam.stream_image_files(n=0, delay=0, stats=False)
else:
    import gui
    app = QApplication(sys.argv)
    window = gui.Window(config.buttons)
    window.show()
    sys.exit(app.exec_())
Exemplo n.º 20
0
@client.event
async def on_message(msg):
    window.new_message(msg)


def guirun():
    sys.exit(app.exec_())


def botrun(token, bot=True):
    client.run(token, bot=bot)


app = QtGui.QApplication(sys.argv)
window = gui.Window(client)

token, ok = QtGui.QInputDialog.getText(window, "Token", "Token:",
                                       QtGui.QLineEdit.Normal)

if ok:
    print("Logging In...")

    t = Thread(target=botrun, args=[token, True])
    t.daemon = True
    t.start()

    guirun()
else:
    sys.exit()
Exemplo n.º 21
0
'''
Conversor de layout para os arquivos de dados gerados para o SIAPC/PAD do TCE/RS

Este conversor de layout lê os dados constantes nos arquivos gerados no layout de
 importação pelo SIAPC/PAD e os trasnforma em outros formatos.

Este arquivo é o módulo principal que chama o módulo Controller.

Este software é distribuído sob a licença MIT.

'''
import sys
import os
import gui
import application

if __name__ == '__main__':
    GUI = gui.Window()
    CONVERSOR = application.App(GUI)
    CONVERSOR.run()
Exemplo n.º 22
0
			}
		#for item in mywin['notebook']['tab_list']['listview'].items:
		#	print item
		#	print item['col_mid']
		#	status = r.status(item['col_mid'])
		#	print status
		#	item['col_status'] = status['result_code']

	def get_balance(self, evt):
		cash, point = self.__get_balance__()
		gui.alert('cash : %u, point : %u' % (cash, point))

ui = smsui()

gui.Window(name='mywin', title='COOLSMS Messaging'
		, resizable=True, height='420px'
		, left='180', top='24'
		, width='600px', bgcolor='#E0E0E0')

# menu
gui.MenuBar(name='menubar', fgcolor='#000000', parent='mywin')
gui.Menu(label='File', name='menu', fgcolor='#000000', parent='mywin.menubar')
gui.MenuItem(label='Quit', help='quit program', name='menu_quit', parent='mywin.menubar.menu')

# tab panel
gui.Notebook(name='notebook', height='211', left='10', top='10', width='590', parent='mywin', selection=0, )
gui.TabPanel(name='tab_setup', parent='mywin.notebook', selected=True, text='Setup')
gui.TabPanel(name='tab_message', parent='mywin.notebook', selected=True, text='Message')
gui.TabPanel(name='tab_list', parent='mywin.notebook', selected=True, text='List')

#### setup #####
# user_id
Exemplo n.º 23
0
def main():
    gui.Window()
Exemplo n.º 24
0
import gui
import os
window = gui.Window("Dental Doc Convertor", layout="pack", master = None)
LSDbtn = window.add_button("          Lostus Smile Dental            ")
JMWRFbtn = window.add_button("         Jvon Clinic Walking Registration Form            ")
PASbtn = window.add_button("         Jvon Clinic Patient A Rules           ")

def LSD():
    os.system('python LSD.py')

def JM_WRF():
    os.system('python JM-WRF.py')

def PAS():
    os.system('python PAS.py')

gui.on("btnPress", LSDbtn, LSD)
gui.on("btnPress", JMWRFbtn, JM_WRF)
gui.on("btnPress", PASbtn, PAS)
#If you don't know what lambda is, it just returns an anonymous, single expression function.
window.start()
Exemplo n.º 25
0
def showTextFileViewer(title, filelist, parent=None, main=False):
    w = gui.Window(title, parent, minsize=(600, 400))
    viewer = TextFileViewer(w.root, filelist, maxSize=-1)
    viewer.grid(row=0, column=0, sticky='news')
    gui.configureWeigths(w.root)
    w.show()
Exemplo n.º 26
0
        guiw.selec_poss_seen = [
            guiw.canvas.create_image(gui.convert(i)[0],
                                     gui.convert(i)[1],
                                     image=guiw.selec_poss_im,
                                     anchor=NW) for i in game.selec_poss
        ]
    except:
        print('invalid selection')


def rgetxy(event):
    try:
        game.right = alpha2[int(event.x / 80) - 1] + str(9 - int(event.y / 80))
    except:
        print('error')
    game.play(guiw)
    for i in guiw.selec_poss_seen:
        guiw.canvas.delete(i)
    if game.winner != None:
        print('the winner is {}'.format(game.winner))
        input()


guiw = gui.Window(game)
guiw.canvas.bind('<Button-1>', lgetxy)
guiw.canvas.bind('<Button-2>', undo)
guiw.canvas.bind('<Button-3>', rgetxy)
guiw.canvas.grid()
guiw.update()
guiw.window.mainloop()
Exemplo n.º 27
0
import gui
import target
import constantes


def execute(*args):
    global unordered
    try:
        unordered.clear(root)
    except:
        pass
    unordered = target.Target()
    unordered.draw(root)
    for _ in range(constantes.sticknum):
        unordered.sort(root)


root = gui.Window('selection sort')
root.window.bind('<Return>', execute)
execute()

root.window.mainloop()
Exemplo n.º 28
0
dot_wall_indices = get_dots_wall_indices(int((len(content) + 1) / 2))

#for idx, val in enumerate(content):
#    print("{:>3})  {}".format(idx, val))
#
#print("len rooms      : {}".format(len(all_rooms)))
#print("rooms      : {}".format(all_rooms))
#print("len walls      : {}".format(len(all_walls)))
#print("walls w val: {}".format(room_with_value_index))
#print("R-val: {}".format(room_with_value_index))
#print("Rooms: {}".format(all_rooms))
print("Walls: {}".format(all_walls))
#print("Print: {}".format(rooms_to_print))
#print("Walls: {}".format(wall_index_per_room))

frame = gui.Window()
print(frame.winfo_screenheight())
frame.geometry("{}x{}+{}+0".format(frame.winfo_screenheight(),
                                   frame.winfo_screenheight(),
                                   int(frame.winfo_screenwidth() / 2)))
frame.update()
print(frame.winfo_screenheight())
frame.set_schermhoogte(frame.winfo_screenheight())
population = Population(gene_length, all_walls_index, all_rooms,
                        wall_index_per_room, room_with_value_index,
                        dot_wall_indices, SETTINGS)
population.calc_fitnesses()
population.sort_pop_on_fitness()
print("Generatie: {:>3} -> Fittest ind: {:>3} -> Worst: {:>3}".format(
    0, population.pop[0].fitness, population.pop[-1].fitness))
gene_to_print = split_gene_into_puzzle(9, population.pop[0].gene)
Exemplo n.º 29
0
    def tradingWindow(self,
                      handle,
                      buddyName='Friend',
                      resource='Water',
                      quantity='0',
                      price='10',
                      trade='sell'):
        '''Opens the trading window at the reciever end for trading
        '''

        #self.font_color = (255,214,150) # Brown
        self.replyhandle = handle
        self.replymessage = ['TradeReply', resource, quantity, price, trade]
        color_blue = (0, 0, 250)
        myfont = pangofont.PangoFont(size=threades.resize_pt(17))
        # Custom Window Style
        win_style = gui.defaultWindowStyle.copy()
        win_style['font'] = myfont
        win_style['bg-color'] = (0, 0, 0)
        win_style['font-color'] = color_blue

        # Calculating position and size of window from the size of the desktop
        position_win = threades.resize_pos((725.0, 42.0))
        size_win = threades.resize_pos((470.0, 180.0))

        # Creating custom label style for the text to be displayed as a message
        labelStyleCopy = gui.defaultLabelStyle.copy()
        labelStyleCopy['wordwrap'] = True
        labelStyleCopy['autosize'] = False
        labelStyleCopy['font'] = myfont
        labelStyleCopy['font-color'] = color_blue
        #labelStyleCopy['font-color'] = font_color

        self.win = gui.Window(position=position_win,
                              size=size_win,
                              parent=threades.desktop,
                              text=_("Trade "),
                              style=win_style,
                              shadeable=False,
                              moveable=False)
        # Creating label
        label_text = '\n' + buddyName + _(
            ' wants to ') + trade + ' ' + quantity + _(
                ' units of ') + resource + '\n at $ ' + price
        message_label = gui.Label(position=threades.resize_pos(
            (5, 5), (470.0, 180.0), self.win.size),
                                  size=threades.resize_pos((460, 120),
                                                           (470.0, 180.0),
                                                           self.win.size),
                                  parent=self.win,
                                  text=label_text,
                                  style=labelStyleCopy)

        # Creating button style
        myfont2 = pangofont.PangoFont(size=threades.resize_pt(16))
        button_style = gui.defaultButtonStyle.copy()
        button_style['font'] = myfont2

        self.button_accept = gui.Button(position=threades.resize_pos(
            (100.0, 130.0), (470.0, 180.0), size_win),
                                        size=threades.resize_pos(
                                            (100.0, 40.0), (470.0, 180.0),
                                            size_win),
                                        parent=self.win,
                                        text=_(" Accept "),
                                        style=button_style)
        self.button_reject = gui.Button(position=threades.resize_pos(
            (300.0, 130.0), (470.0, 180.0), size_win),
                                        size=threades.resize_pos(
                                            (100.0, 40.0), (470.0, 180.0),
                                            size_win),
                                        parent=self.win,
                                        text=_(" Reject "),
                                        style=button_style)

        self.button_accept.onClick = self.checkTrade
        self.button_reject.onClick = self.closeWin

        sleep(6)
        if self.win:
            self.win.close()
Exemplo n.º 30
0
def Restart():
    CloseEndInstance()
    variables.window.CloseGUI()
    variables.window = gui.Window()
    StartGame()