Exemplo n.º 1
0
def adicionarMusica():
    global listaNomes, opcoes, lista, musica_e, z, fundo, cor_fundo_escolhida, botao_play, valor_play_pause
    jatem = False
    root = Tk()
    root.geometry('0x0')
    root.overrideredirect(False)
    root.iconbitmap('icones\icon_player.ico')
    opcoes['defaultextension'] = '.mp3'
    opcoes['filetypes'] = [('arquivos .mp3', '.mp3')]
    opcoes['initialdir'] = ''  # será o diretório atual
    opcoes['initialfile'] = ''  #apresenta todos os arquivos no diretorio
    opcoes['title'] = 'Selecione a música'
    nome_musica = askopenfile(mode='r', **opcoes)
    root.destroy()
    root.mainloop()
    try:
        fundo.fill(cor_fundo_escolhida)
        d = nome_musica.name
        f = d.split('/')
        w = f[len(f) - 1]
        w = w.split('.')
        if d in listaNomes:
            pyautogui.alert(text='A música \"' + w[0] +
                            '\" já encontra-se na lista!',
                            title='',
                            button='OK')
            listaNomes = listaNomes
            lista = lista
            jatem = True
        else:
            try:
                pygame.mixer.music.load(d)
                pygame.mixer.music.play()
                listaNomes.append(nome_musica.name)
                lista.append(w[0])
                musica_e = w[0]
                z = len(lista) - 1
            except:
                pyautogui.alert(text='Não foi possível reproduzir a música!',
                                title='Erro',
                                button='OK')
        if valor_play_pause == 1 and jatem == False:
            botao_play = pygame.image.load("icones\icon_play_pause.png")
            valor_play_pause = 0
    except AttributeError as error:
        listaNomes = listaNomes
        lista = lista
    salvarLista()
Exemplo n.º 2
0
def edit():
    global editor
    editor = Tk()
    editor.title("Update a Golfer")
    editor.geometry('400x150')

    # Create a Database or Connect to one
    conn = odbc.connect('Driver={SQL Server};'
                        'Server=DESKTOP-SCL1250\SQLEXPRESS01;'
                        'Database=tgt;'
                        'Trusted_Connection=yes;')
    c = conn.cursor()

    record_id = delete_box.get()
    # Query the Database
    sql = 'SELECT * from golfers WHERE golfer_id = ?'
    val = record_id
    c.execute(sql, val)
    records = c.fetchall()

    # Create global variables for text box names
    global last_name_editor
    global first_name_editor
    global tour_code_editor

    # Create Text Boxes
    #golfer_id = Entry(golfers, width=30)
    #golfer_id.grid(row=0, column=1, padx=20)
    last_name_editor = Entry(editor, width=30)
    last_name_editor.grid(row=1, column=1, padx=20, pady=(10, 0))
    first_name_editor = Entry(editor, width=30)
    first_name_editor.grid(row=2, column=1, padx=20)
    tour_code_editor = Entry(editor, width=30)
    tour_code_editor.grid(row=3, column=1, padx=20)

    # Create Text Box Labels
    #golfer_id_label = Label(golfers, text="Golfer ID")
    #golfer_id_label.grid(row=0, column=0)
    last_name_label = Label(editor, text="Last Name")
    last_name_label.grid(row=1, column=0, pady=(10, 0))
    first_name_label = Label(editor, text="First Name")
    first_name_label.grid(row=2, column=0)
    tour_code_label = Label(editor, text="Tour Code")
    tour_code_label.grid(row=3, column=0)

    # Loop Through Results
    for record in records:
        last_name_editor.insert(0, record[1])
        first_name_editor.insert(0, record[2])
        tour_code_editor.insert(0, record[3])

    # Create an Save Button
    save_btn = Button(editor, text='Save Record', command=update)
    save_btn.grid(row=4, column=0, columnspan=2, pady=10, padx=10, ipadx=132)

    # Update a Record
    sql = 'UPDATE golfers WHERE golfer_id= ?'
    val = delete_box.get()
    c.execute(sql, val)

    # Commit Changes
    c.commit()
    # Close Connection
    c.close()

    # Clear boxes
    editor.destroy()
Exemplo n.º 3
0
class Display:
    def __init__(self, controller, win_main=""):
        self.controller = controller

        self.root = Tk()
        self.root.title("Graphs - " + win_main)
        self.tabs = n = ttk.Notebook(self.root, width=1400, height=650)
        n.grid(column=0, row=0, padx=5, pady=5)

        frm = []

        idx = -1

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="Cross Section")
        self.tab_cut = idx

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="Pand Design")
        self.tab_design = idx

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="Boundary Condition")
        self.tab_bc = idx

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="X-Y Delta n or Stress")
        self.tab_xy = idx

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="R-theta Stress")
        self.tab_rtheta = idx

        idx += 1
        frm.append(ttk.Frame(n))
        n.add(frm[idx], text="Stress Tensor Visualization")
        self.tab_el = idx

        # -----------------------------------------------------------------
        idx = -1
        fig = []
        canvas = []

        # frame #1: X-Y stress
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_xy = fig[idx]
        controller.ax_xstress = fig[idx].add_subplot(131, aspect='equal')
        controller.ax_ystress = fig[idx].add_subplot(132, aspect='equal')
        controller.ax_xystress = fig[idx].add_subplot(133, aspect='equal')

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_xy]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_xy] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_xy]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------------------------------------------------------
        # frame #2: R-theta stress
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_rtheta = fig[idx]
        controller.ax_rstress = fig[idx].add_subplot(121, aspect='equal')
        controller.ax_tstress = fig[idx].add_subplot(122, aspect='equal')

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_rtheta]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_rtheta] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_rtheta]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------------------------------------------------------
        # frame #3: boundary condition
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_bc = fig[idx]
        controller.ax_bc = fig[idx].add_subplot(111)

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_bc]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_bc] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_bc]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------------------------------------------------------
        # frame #4: cross-section
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_cut = fig[idx]
        controller.ax_cut1 = fig[idx].add_subplot(121)
        controller.ax_cut2 = fig[idx].add_subplot(122)

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_cut]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_cut] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_cut]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------------------------------------------------------
        # frame #5: design
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_design = fig[idx]
        controller.ax_design = fig[idx].add_subplot(111)

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_design]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_design] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_design]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------------------------------------------------------
        # frame #6: stress tensor visualization
        idx += 1

        fig.append(Figure())
        # naming....
        controller.fig_el = fig[idx]
        controller.ax_el = fig[idx].add_subplot(111, aspect='equal')

        canvas.append(FigureCanvasTkAgg(fig[idx], master=frm[self.tab_el]))
        # canvas[idx].show()
        canvas[idx].draw()

        canvas[idx].get_tk_widget().pack(side=TOP)

        # NavigationToolbar2TkAgg( canvas[idx], frm[self.tab_el] ).update()
        NavigationToolbar2Tk(canvas[idx], frm[self.tab_el]).update()
        canvas[idx]._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        # -----------------
        n.pack(fill=BOTH, expand=1)

        # self.root.mainloop()

        # self.init_fill() # doesn't work

        return

    # -------------------------------------------
    def quit(self):
        self.root.destroy()

        return

    # -------------------------------------------
    def clear_all(self):
        """clear all graphs"""
        header = "clear_all(): "

        print(header, " x-y plot")
        self.controller.ax_xstress.cla()
        self.controller.ax_ystress.cla()
        self.controller.ax_xystress.cla()
        self.controller.ax_xstress.figure.canvas.draw()

        print(header, " r-theta plot")
        self.controller.ax_rstress.cla()
        self.controller.ax_tstress.cla()
        self.controller.ax_rstress.figure.canvas.draw()

        print(header, " BC plot")
        self.controller.ax_bc.cla()
        self.controller.ax_bc.figure.canvas.draw()

        print(header, " cross-section plot")
        self.controller.ax_cut1.cla()
        self.controller.ax_cut2.cla()
        self.controller.ax_cut1.figure.canvas.draw()

        print(header, " design plot")
        self.controller.ax_design.cla()
        self.controller.ax_design.figure.canvas.draw()

        print(header, " tensor visual plot")
        self.controller.ax_el.cla()
        self.controller.ax_el.figure.canvas.draw()

        return

    # ----------------------------------------------------
    # plotting the initial flat z profile fixes the glitch in removing
    # the colorbar; otherwise the first time the profiles are plotted
    # it is a little smaller (thereafter, subsequent plots are all the
    # same size, but slightly larger).
    def init_fill(self):
        rext = 1.0
        Ns = 51
        x, y = np.mgrid[-rext:rext:1j * Ns, -rext:rext:1j * Ns]
        z = np.zeros_like(x)

        self.controller.ax_xstress.pcolor(x, y, z, cmap=plt.cm.coolwarm)
        self.controller.ax_ystress.pcolor(x, y, z, cmap=plt.cm.coolwarm)
        self.controller.ax_xystress.pcolor(x, y, z, cmap=plt.cm.coolwarm)

        self.controller.ax_rstress.pcolor(x, y, z, cmap=plt.cm.coolwarm)
        self.controller.ax_tstress.pcolor(x, y, z, cmap=plt.cm.coolwarm)

        return