Esempio n. 1
0
    def __init__(self):
        self.root = tk.Tk()
        self.root.title("Flash")
        self.label = tk.Label(
            self.root,
            width=self.root.winfo_reqwidth(),
            height=self.root.winfo_reqheight(),
            text="Create new file",
        )
        self.tab = Tab(self.root)
        self.txt, self.tb = self.tab.add_tab("untitled")
        self.height, self.width = (
            self.root.winfo_reqheight(),
            self.root.winfo_reqwidth(),
        )
        self.txt.config(
            height=self.height,
            width=self.width,
        )
        self.footer = tk.Label(self.root)

        self.footer.pack(fill="both", expand="yes", side=tk.BOTTOM)
        self.txt.pack(fill="both", expand="yes")
        self.tb.pack(fill="both", expand="yes")
        self.label.pack()
        self.root.geometry("998x646")
        self.root.minsize(width=400, height=200)
Esempio n. 2
0
    def __init__(self, parent, width, height):
        Tab.__init__(self, parent, width, height)
        self.width = width
        self.height = height
        self.padding = 10
        self.tableWidth = self.width / 3
        self.tableHeight = self.height / 2
        self.playersTab = None
        self.columnconfigure(3, minsize=self.tableWidth)
        self.tables = [
            Table(self, self.tableWidth, self.tableHeight, 1),
            Table(self, self.tableWidth, self.tableHeight, 2),
            Table(self, self.tableWidth, self.tableHeight, 3),
            Table(self, self.tableWidth, self.tableHeight, 4)
        ]
        self.tables[0].grid(row=0, column=0)
        self.tables[1].grid(row=0, column=1)
        self.tables[2].grid(row=1, column=0)
        self.tables[3].grid(row=1, column=1)

        self.tableView = ttk.Frame(self)
        self.textFont = font.Font(size=32)
        self.label = tk.Label(self.tableView,
                              text="Table #:",
                              font=self.textFont)
        self.label.grid(row=0, column=0)
        self.tableNumber = tk.Label(self.tableView)
        self.listHeight = int(self.height / 18)
        self.listWidth = int(self.width / 18)
        self.playerList = tk.Listbox(self.tableView,
                                     width=self.listWidth,
                                     height=self.listHeight,
                                     activestyle="none")
        self.playerList.grid(row=1, column=0)
        self.tableView.grid(row=0, column=2, rowspan=2, columnspan=2)
Esempio n. 3
0
 def append( self, window ):
     Frame.append( self, window )
     tab = Tab( self, window )
     window.tab = tab
     self.tabs.append( tab )
     if not self.visible():
         tab.hide()
     tab.set_text( window.get_title() )
     # shouldn't some of the stuff above be moved into tab_manage?
     window.tab_manage()
Esempio n. 4
0
 def seleciona_individuo_cruzamento(self):
     melhor = float('inf')
     melhor_individuo = self.copia_populacao[0]
     for individuo in self.copia_populacao:
         individuo_AF = Tab(individuo).AF()
         if (individuo_AF < melhor and random.random() <
             (individuo_AF / self.soma_AF())):
             print("teste")
             melhor = Tab(individuo).AF()
             melhor_individuo = individuo
     return melhor_individuo
Esempio n. 5
0
def test_sort():
    "make a table"
    t = Tab(csv("../data/auto93.csv"))
    tmp = ordered(t.rows(), t.cols)
    for col in t.cols.y:
        print(col.txt, col.mid(), col.sd() * .35)
    for one in tmp[:5]:
        print(t.cols.ys(one))
    print("")
    for one in tmp[-5:]:
        print(t.cols.ys(one))
Esempio n. 6
0
    def __init__(self, parent, width, height):
        Tab.__init__(self, parent, width, height)
        self.width = width
        self.height = height
        self.playersAmount = len(self.players)
        self.playersLists = []
        self.isShuffled = False

        self.listOfPlayers = tk.Listbox(self,
                                        font="Times 16",
                                        height=int(self.height / 24),
                                        width=int(self.width / 20),
                                        activestyle="none")
        for i in range(len(self.players)):
            self.listOfPlayers.insert(i, self.players[i])
        self.listOfPlayers.grid(row=0, column=0)

        self.panel = ttk.Frame(self)

        self.adding = ttk.Frame(self.panel)
        self.addLabel = tk.Label(self.adding,
                                 text="Player name:",
                                 font="Times 16")
        self.addLabel.grid(row=0, column=0, padx=20)
        self.addField = tk.Entry(self.adding, font="Times 16")
        self.addField.grid(row=0, column=1)
        self.addButton = tk.Button(self.adding,
                                   text="Add",
                                   font="Times 16",
                                   command=self.addPlayer)
        self.addButton.grid(row=1, column=0, ipadx=15)
        self.adding.grid(row=0, column=0, pady=150)

        self.removing = ttk.Frame(self.panel)
        self.removeLabel = tk.Label(self.removing,
                                    text="Player name:",
                                    font="Times 16")
        self.removeLabel.grid(row=0, column=0, padx=20)
        self.removeField = tk.Entry(self.removing, font="Times 16")
        self.removeField.grid(row=0, column=1)
        self.removeButton = tk.Button(self.removing,
                                      text="Remove",
                                      font="Times 16",
                                      command=self.removePlayer)
        self.removeButton.grid(row=1, column=0)
        self.removing.grid(row=2, column=0, pady=150)

        self.shuffleButton = tk.Button(self.panel,
                                       text="Shuffle",
                                       font="Times 16",
                                       command=self.shuffle)
        self.shuffleButton.grid(row=4, column=3, ipady=10, ipadx=25, padx=20)

        self.panel.grid(row=0, column=1, rowspan=2, columnspan=3)
Esempio n. 7
0
 def __init__(self, tab_option, font, parent):
     Tab.__init__(self, tab_option)
     self.build_log()
     # Logs history
     self.history = []
     self.history.append("Program Started Successfully")
     self.parent = parent
     self.tracker = 0
     # Set font
     self.font = font
     # Automatically open when a message is sent to the log
     self.auto = True
Esempio n. 8
0
def diveg(f="data/weather.csv", loud=False):
    the = about.defaults()
    t = Tab(file=f)
    if len(t.rows) > 2000: the.tiny = 0.66
    all = sorted(clusters.div(t, the, cols=t.cols.x, loud=True))
    print([col.txt for col in t.cols.y])
    print(rs(t.y(), 3), "<== baseline")
    for x in all:
        print(rs(x.y(), 3))
    for span in sorted(all[0].bins(all[-1], the)):
        print(span)
    print(round(random.random(), 3), the)
Esempio n. 9
0
 def new_tab(self,x=None):
     if self.tabs:
         previous_tab = self.current_tab()
         current_folder = previous_tab.get_current_folder()
     else:
         current_folder = os.curdir
     tab = Tab(self.notebook,self.statusbar,current_folder)
     self.tabs.append(tab)
     self.notebook.set_current_page(len(self.tabs)-1)
     tab.focus()
     #reset the flag to indicate that we no longer
     #have just the original "New Document" tab
     self.only_first_tab = 0
Esempio n. 10
0
    def __init__(self, parent, width, height):
        Tab.__init__(self, parent, width, height)

        self.width = width
        self.height = height

        self.currentLevel = 0
        self.maxLevel = len(self.levels)

        self.timerTitle = tk.Label(self, text="Timer", font=self.topFont)
        self.timerTitle.grid(row=1, column=2, columnspan=4, ipady=40)
        self.timer = tk.Label(self,
                              text="0 : 0",
                              font=self.topFont,
                              borderwidth=2,
                              relief="groove")
        self.timer.grid(row=3, column=2, columnspan=4, ipady=10, ipadx=10)
        self.level = tk.Label(self,
                              text=self.levels[self.currentLevel],
                              font=self.midFont,
                              width=30)
        self.level.grid(row=5, column=0, rowspan=1, columnspan=9, pady=180)

        self.minLbl = tk.Label(self, text="Min: ", font=self.botFont, padx=20)
        self.minLbl.grid(row=7, column=0, ipady=40, ipadx=10)
        self.minTbox = tk.Entry(self, font=self.botFont, width="5")
        self.minTbox.grid(row=7, column=1, ipady=10, ipadx=5)
        self.secLbl = tk.Label(self, text="Sec: ", font=self.botFont, padx=20)
        self.secLbl.grid(row=7, column=2, ipady=40, ipadx=10)
        self.secTbox = tk.Entry(self, font=self.botFont, width="5")
        self.secTbox.grid(row=7, column=3, ipady=10, ipadx=5)

        self.startButton = tk.Button(self,
                                     text="Start",
                                     font=self.botFont,
                                     command=self.start)
        self.startButton.grid(row=7, column=4, ipady=10, ipadx=15, padx=20)
        self.stopButton = tk.Button(self,
                                    text="Stop",
                                    font=self.botFont,
                                    command=self.stop,
                                    state="disabled")
        self.stopButton.grid(row=7, column=5, ipady=10, ipadx=15, padx=20)
        self.resetButton = tk.Button(self,
                                     text="Reset",
                                     font=self.botFont,
                                     command=self.reset,
                                     state="disabled")
        self.resetButton.grid(row=7, column=6, ipady=10, ipadx=15, padx=20)
Esempio n. 11
0
    def read(self, index):
        putanja = self.dock.model.filePath(index)
        if os.path.isdir(putanja):
            return

        ista_putanja = False
        for i in range(len(self.lista_putanja)):
            if putanja == self.lista_putanja[i]:
                ista_putanja = True
                return
        if not ista_putanja:
            self.lista_putanja.append(putanja)
            if putanja.find(".sql") != -1:
                self.connection = mysql.connector.connect(user="******", password="******", host="127.0.0.1", database="projekat")
                self.csor = self.connection.cursor()
                putanja = "podaci\metaPodaci\projekat_meta_podaci.csv"
                meta_podaci = citanje_meta_podataka(putanja, True)
                self.imena_tabela = meta_podaci[4].split(",")

                self.treeView = QTreeView()
                self.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
                self.treeView.customContextMenuRequested.connect(self.dugme_baza)
                
                model = QStandardItemModel(parent=self.dock.tree.sub_layout)
                item = QStandardItem("zatvori")
                item.setEditable(False)
                model.appendRow(item)
                for text in self.imena_tabela:
                    item = QStandardItem(text)
                    item.setEditable(False)
                    model.appendRow(item)
                
                self.treeView.setModel(model)
                self.treeView.clicked.connect(self.dugme_baza)
                self.treeView.PositionAtBottom

                si = self.dock.tree.sub_layout.sizeHint()
                si.setWidth(self.dock.width())
                si.setHeight(200)
                self.treeView.setFixedSize(si.width(), si.height())

                self.treeView.setHeaderHidden(True)
                self.dock.tree.sub_layout.addWidget(self.treeView)
                self.dock.tree.sub_layout.setAlignment(self.treeView, QtCore.Qt.AlignBottom)
                return

            tab = Tab(putanja, parent=self.central_widget)
            tab.pocetna_strana = self

            if putanja != "":
                tab.read()
            else:
                tab.read(putanja)
            tab.btn_down.clicked.connect(self.otvori_tabelu_dete)
            tab.btn_up.clicked.connect(self.otvori_tabelu_roditelj)
            tab.naziv = tab.meta_podaci[0]
            self.central_widget.addTab(tab, tab.naziv)
            self.central_widget.setCurrentIndex(self.central_widget.currentIndex()+1)
Esempio n. 12
0
def diveg():
  the=about.defaults()
  t=Tab(file=the.data)
  print(the.data)
  for _ in  range(10):
    print("")
    keys(t,the)
Esempio n. 13
0
    def drawtab(self, filename=""):
        if filename != "":
            self.tabFile = filename
        self.tab = Tab(self.tabFile)
        grid = self.tab.getTabData()
        self.tabNumRows = len(grid) - 1

        # Clear canvas in case a bar was removed
        self.tabCanvas.canvas.clear()
        with self.tabCanvas.canvas:
            for i in range(len(grid)):
                for j in range(len(grid[i])):
                    if isinstance(grid[i][j], str):
                        Rectangle(
                            source=self.ATLAS_PREFIX + grid[i][j],
                            pos=(j * self.CHAR_WIDTH, (self.tabNumRows - i) * self.CHAR_HEIGHT),
                            size=(self.CHAR_WIDTH, self.CHAR_HEIGHT),
                        )
                    elif isinstance(grid[i][j], list):
                        for item in grid[i][j]:
                            Rectangle(
                                source=self.ATLAS_PREFIX + item,
                                pos=(j * self.CHAR_WIDTH, (self.tabNumRows - i) * self.CHAR_HEIGHT),
                                size=(self.CHAR_WIDTH, self.CHAR_HEIGHT),
                            )
Esempio n. 14
0
def go(f="data/weather.csv",silent=True):
  the=about.defaults()
  t=Tab(file=f)
  for n,here in enumerate(t.rows):
    tmp=t.around(here,the)
    me= tmp[0][1]
    close  = tmp[1][1]
    far = t.far(here,the)
    further= tmp[-1][1]
    if not silent:
      print("")
      print(n,here.cells)
      print(n,me.cells)
      print(n,far.cells)
      print(n,further.cells)
    assert tmp[0][0] <= tmp[1][0] < tmp[-1][0]
Esempio n. 15
0
    def addTab(self):

        text, ok = QInputDialog.getText(self, 'Name your tab', 'Name')
        if ok:
            name = str(text)
            widget = Tab(self)
            self.tab_widget.addTab(widget, name)
            self.tab_widget.setCurrentWidget(widget)
Esempio n. 16
0
 def addTab(self,t,widget):
     if type(t) == type("abc"):
         tab=Tab()
         tab.setCaption(t)
         self.addTab(tab,widget)
     elif isinstance(t,Tab) == True:
         t.setTabbedArea(self)
         t.addActionListener(self)
         
         self.mTabContainer.add(t)
         self.mTabs.append( (t,widget) )
         
         if self.mSelectedTab == None:
             self.setSelectedTab(t)
             
         self.adjustTabPositions()
         self.adjustSize()
Esempio n. 17
0
    def dugme_baza(self, model_indeks):
        indeks = model_indeks.row()
        if indeks == 0:
            self.treeView.close()
            for i in range(len(self.lista_putanja)):
                if self.lista_putanja[i].find(".sql") != 1:
                    self.lista_putanja.pop(i)
                    break

            self.central_widget.setCurrentIndex(indeks)
            brojac = 0
            while len(self.lista_baza) != 0:
                tab = self.central_widget.currentWidget()
                if tab.is_baza:
                    for i in range(brojac, len(self.lista_baza)):
                        if self.lista_baza[brojac] == tab.indeks:
                            self.lista_baza.pop(brojac)
                            self.central_widget.removeTab(indeks)
                            break
                        else:
                            brojac += 1
                else:
                    indeks += 1
                    self.central_widget.setCurrentIndex(indeks)

            self.csor.close()
            self.connection.close()
            return
        else:
            indeks -= 1
            for i in range(len(self.lista_baza)):
                if self.lista_baza[i] == indeks:
                    return
            self.lista_baza.append(indeks)

        tab = Tab(parent=self.central_widget)
        tab.pocetna_strana = self
        tab.indeks = indeks
        tab.naziv = self.imena_tabela[indeks]
        
        nova_putanja = "podaci\\metaPodaci\\"
        nova_putanja += self.imena_tabela[indeks][0].lower()
        
        for s in range(1, len(self.imena_tabela[indeks])):
            if self.imena_tabela[indeks][s].isupper():
                nova_putanja += "_" + self.imena_tabela[indeks][s].lower()
            else:
                nova_putanja += self.imena_tabela[indeks][s]
        
        nova_putanja += "_meta_podaci_sql.csv"

        tab.read(nova_putanja)
        tab.btn_down.clicked.connect(self.otvori_tabelu_dete)
        tab.btn_up.clicked.connect(self.otvori_tabelu_roditelj)
        self.central_widget.addTab(tab, tab.naziv)
        self.central_widget.setCurrentIndex(self.central_widget.currentIndex()+1)
Esempio n. 18
0
def diveg(f="data/weather.csv",loud=False):
  the=about.defaults()
  t=Tab(file=f)
  all = sorted(t.rows)
  for x in all: print(x.y())
  return 1
  c=Clusters(t,the,cols=t.cols.y, loud=loud)
  print([col.txt for col in t.cols.y])
  all = sorted(c.all)
  for t1 in c.all: print(rs(t1.y()))
  for span in all[0].bins(all[-1],the): print(span)
  print(the)
Esempio n. 19
0
    def Add(self, page, focus, resort = True):
        """
            Adds a tab to the bar.  Should only be used by parent NoteBook.
            page - page in PageContainer the tab is to be associated with
            focus - whether that tab should steal focus from current tab
        """
        tab = Tab(self, page, skinkey = self.tabskin)
        tab.Bind(wx.EVT_CONTEXT_MENU, self.ShowMenu)
        tab.Show(False)
        self.tabs.append(tab)

        if focus:
            wx.CallAfter(tab.SetActive, True)

        elif resort:
            if self.side_tabs:
                self.ReVgenerate()
            else:
                self.Regenerate(True)

        return tab
Esempio n. 20
0
 def append(self, window):
     Frame.append(self, window)
     tab = Tab(self, window)
     window.tab = tab
     self.tabs.append(tab)
     if not self.visible():
         tab.hide()
     tab.set_text(window.get_title())
     # shouldn't some of the stuff above be moved into tab_manage?
     window.tab_manage()
Esempio n. 21
0
class Window:
    def __init__(self):
        self.root = tk.Tk()
        self.root.title("Flash")
        self.label = tk.Label(
            self.root,
            width=self.root.winfo_reqwidth(),
            height=self.root.winfo_reqheight(),
            text="Create new file",
        )
        self.tab = Tab(self.root)
        self.txt, self.tb = self.tab.add_tab("untitled")
        self.height, self.width = (
            self.root.winfo_reqheight(),
            self.root.winfo_reqwidth(),
        )
        self.txt.config(
            height=self.height,
            width=self.width,
        )
        self.footer = tk.Label(self.root)

        self.footer.pack(fill="both", expand="yes", side=tk.BOTTOM)
        self.txt.pack(fill="both", expand="yes")
        self.tb.pack(fill="both", expand="yes")
        self.label.pack()
        self.root.geometry("998x646")
        self.root.minsize(width=400, height=200)

    def footer_elements(self):
        while True:
            try:
                for i in w.tab.txt_collection:
                    word_count = len(i.get("1.0", tk.END).split())
                    character_count = len(i.get("1.0", tk.END)) - i.get(
                        "1.0", tk.END).count("\n")
                    mouse_pos = i.index(tk.INSERT)
                    line, column = (int(num) for num in mouse_pos.split("."))
                    self.footer.configure(
                        text=(f'word count: {word_count}   '
                              f'character count: {character_count}     '
                              f'lines number: {line}    '
                              f'columns number: {column}'),
                        anchor=tk.E,
                    )
                self.root.update()
            except (tk.TclError, ValueError):
                break
Esempio n. 22
0
    def __init__(self, root, **kwargs):

        # Class variable initialization
        self._root = root
        self._config = root._config
        self._tabs = {}

        # Initialize notebook widget
        new_widget(root, super(), **kwargs)

        # Add tabs to notebook
        for tab in self._config.get_tab_names():
            self._tabs[tab] = Tab(self, **kwargs)
            self.add(self._tabs[tab], text=tab)

        return None
Esempio n. 23
0
class TabArea(BoxLayout):
    tabCanvas = ObjectProperty(None)
    slide = ObjectProperty(None)
    scrlv = ObjectProperty(None)
    mainBoxLayout = ObjectProperty(None)

    # Constant declaration
    CHAR_WIDTH = 32
    CHAR_HEIGHT = CHAR_WIDTH
    ATLAS_PREFIX = "atlas://Assets/main/"
    ACCEPT_CHARS = ["|", "-", "x", "X", "\\", "/", "~", "*", "h", "p", "b", "r"]
    for num in range(25):
        ACCEPT_CHARS.append(str(num))

        # Determines if tab can be edited
    editable = False
    inputText = ""

    def scroll_change(self, scrl, instance, value):
        scrl.scroll_x = value

    def slider_change(self, slide, instance, value):
        if value >= 0:
            slide.value = value

            # Set the tab as editable or not editable
            # Allows user to edit the tab if True

    def setEditable(self, setter=True):
        # Adds the 'extend tab' button to the right of the tab
        if not self.editable and setter:
            self.mainBoxLayout.add_widget(Button(text="Extend Tab", size_hint=(0.1, 0.5), on_release=self.extendTab))
            self.mainBoxLayout.add_widget(Button(text="Reduce Tab", size_hint=(0.1, 0.5), on_release=self.reduceTab))

        self.editable = setter

        # Extend each line of the tab by one blank bar

    def extendTab(self, kivyAction):
        self.tab.extendByOneBar()
        self.drawtab()

        # Reduce each line of the tab by one bar

    def reduceTab(self, kivyAction):
        self.tab.reduceByOneBar()
        self.drawtab()

        # A callback function to get the user input from the textInput module

    def setInputText(self, instance, value):
        self.inputText = str(value)

        # Detects a user click on the tab, and allows editing if the option is set

    def tabTouched(self, touch):

        if self.editable:
            # Get the indices of the corresponding character of the tab
            xpos = int(touch.x)
            ypos = int(touch.y)
            xIndex = xpos // 32
            yIndex = self.tabNumRows - (ypos // 32)
            print("Coords: " + str(yIndex) + " " + str(xIndex))
            print("This is what your toggle button is: ", toggle_button)
            curr_val = self.tab.getTabData(yIndex, xIndex)
            double_digit = False
            modifier = True
            if len(curr_val[1]) != 1:
                double_digit = True
            print("this is the eval of double_digit: ", double_digit)
            if double_digit == True:
                double_val = self.tab.getTabData(yIndex, xIndex + 2)
                print(
                    "her is solksdflasf: ",
                    self.tab.getTabData(yIndex, xIndex + 1),
                    " ",
                    self.tab.getTabData(yIndex, xIndex),
                    " ",
                    self.tab.getTabData(yIndex, xIndex + 2),
                )
                if (
                    self.tab.getTabData(yIndex, xIndex) in ("bar", "tbar", "plusbar", "mute", "slide", "vibrato")
                    or self.tab.getTabData(yIndex, xIndex)[0] == "norm"
                ):
                    modifier = False
                    # if ((double_val in ('bar' , 'tbar' , 'plusbar' , 'mute' , 'slide' , 'vibrato')) or double_val[1].isdigit()):
                    # modifier = False
            else:
                print(
                    "her is solksdflasf: ",
                    self.tab.getTabData(yIndex, xIndex + 1),
                    " ",
                    self.tab.getTabData(yIndex, xIndex)[0],
                    " ",
                    self.tab.getTabData(yIndex, xIndex + 2),
                )
                next_val = self.tab.getTabData(yIndex, xIndex + 1)
                if (
                    self.tab.getTabData(yIndex, xIndex) in ("bar", "tbar", "plusbar", "mute", "slide", "vibrato")
                    or self.tab.getTabData(yIndex, xIndex)[0] == "norm"
                ):
                    modifier = False
                    # if ((next_val in ('bar' , 'tbar' , 'plusbar' , 'mute' , 'slide' , 'vibrato')) or next_val[1].isdigit()):
                    # modifier = False
            print("Result of modifier: ", modifier)
            if toggle_button == "slide":
                self.inputText = "/"
                print("This is the inputText: ", self.inputText)
                self.writeToTab(0, yIndex, xIndex)
                if double_digit == True:
                    self.inputText = "-"
                    self.writeToTab(0, yIndex, xIndex + 1)
                    if modifier == True:
                        self.writeToTab(0, yIndex, xIndex + 2)
                else:
                    self.inputText = "-"
                    if modifier == True:
                        self.writeToTab(0, yIndex, xIndex)
            elif toggle_button == "vibrato":
                self.inputText = "~"
                print("This is the inputText: ", self.inputText)
                self.writeToTab(0, yIndex, xIndex)
                if double_digit == True:
                    self.inputText = "-"
                    self.writeToTab(0, yIndex, xIndex + 1)
                    if modifier == True:
                        self.writeToTab(0, yIndex, xIndex + 2)
                else:
                    self.inputText = "-"
                    if modifier == True:
                        self.writeToTab(0, yIndex, xIndex)
            elif toggle_button == "squealie":
                self.inputText = "*"
                print("This is the inputText: ", self.inputText)
                if double_digit == False:
                    self.writeToTab(0, yIndex, xIndex + 1)
                else:
                    self.writeToTab(0, yIndex, xIndex + 2)
            elif toggle_button == "hammeron":
                self.inputText = "h"
                print("This is the inputText: ", self.inputText)
                if double_digit == False:
                    self.writeToTab(0, yIndex, xIndex + 1)
                else:
                    self.writeToTab(0, yIndex, xIndex + 2)
            elif toggle_button == "pulloff":
                self.inputText = "p"
                print("This is the inputText: ", self.inputText)
                if double_digit == False:
                    self.writeToTab(0, yIndex, xIndex + 1)
                else:
                    self.writeToTab(0, yIndex, xIndex + 2)
            else:
                next_val = self.tab.getTabData(yIndex, xIndex + 1)
                if double_digit == False:
                    if not (next_val[1].isdigit() or next_val[0] == "-"):
                        self.inputText = "-"
                        self.writeToTab(0, yIndex, xIndex + 1)
                else:
                    self.inputText = "-"
                    self.writeToTab(0, yIndex, xIndex + 1)
                    if (
                        self.tab.getTabData(yIndex, xIndex + 2)
                        not in ("bar", "tbar", "plusbar", "mute", "slide", "vibrato")
                    ) or not self.tab.getTabData(yIndex, xIndex + 2)[1].isdigit():
                        self.writeToTab(0, yIndex, xIndex + 2)
                textbox = TextInput(text="", multiline=False)
                inputPopup = Popup(
                    title="Fret Number",
                    content=textbox,
                    size_hint=(None, None),
                    size=(150, 100),
                    # pos = (xpos, ypos)
                )
                textbox.bind(on_text_validate=inputPopup.dismiss)
                textbox.bind(text=self.setInputText)
                inputPopup.bind(on_dismiss=partial(self.writeToTab, row=yIndex, col=xIndex))
                inputPopup.open()
                # call tab to rewrite file at (yIndex, xIndex) with input if valid

                # Write input to the tab using tab's write function

    def writeToTab(self, instance, row, col):
        if self.editable:
            # Validate input
            if self.inputText in self.ACCEPT_CHARS:
                # Write to tab
                print("We are writing ", self.inputText, " to the tab!")
                self.tab.write(row, col, self.inputText)
                self.drawtab()

                # Draws the tab to the screen from the given file using a Tab object

    def drawtab(self, filename=""):
        if filename != "":
            self.tabFile = filename
        self.tab = Tab(self.tabFile)
        grid = self.tab.getTabData()
        self.tabNumRows = len(grid) - 1

        # Clear canvas in case a bar was removed
        self.tabCanvas.canvas.clear()
        with self.tabCanvas.canvas:
            for i in range(len(grid)):
                for j in range(len(grid[i])):
                    if isinstance(grid[i][j], str):
                        Rectangle(
                            source=self.ATLAS_PREFIX + grid[i][j],
                            pos=(j * self.CHAR_WIDTH, (self.tabNumRows - i) * self.CHAR_HEIGHT),
                            size=(self.CHAR_WIDTH, self.CHAR_HEIGHT),
                        )
                    elif isinstance(grid[i][j], list):
                        for item in grid[i][j]:
                            Rectangle(
                                source=self.ATLAS_PREFIX + item,
                                pos=(j * self.CHAR_WIDTH, (self.tabNumRows - i) * self.CHAR_HEIGHT),
                                size=(self.CHAR_WIDTH, self.CHAR_HEIGHT),
                            )
Esempio n. 24
0
 def soma_AF(self):
     soma = 0
     for individuo in self.populacao:
         soma += Tab(individuo).AF()
     return soma
Esempio n. 25
0
    def add_tab_page(self):
        """Add a new empty tab.

        Create empty query panel and empty result table.
        """
        empty_tab = Tab()
        self.latest_query_index += 1
        self.addTab(empty_tab,
                    'Query {idx}'.format(idx=self.latest_query_index))
        if self.tabBar().count() > 1:
            current_tab_gdb = getattr(self.widget(self.currentIndex()), 'gdb',
                                      None)
            if current_tab_gdb:
                empty_tab.gdb = current_tab_gdb
                empty_tab.connected_gdb_path_label.setText(
                    self.widget(self.currentIndex()).gdb.path)
                empty_tab.connect_to_geodatabase(evt=None,
                                                 triggered_with_browse=False)
                empty_tab._fill_toc()
            else:  # the first tab
                empty_tab.connected_gdb_path_label.setText(
                    not_connected_to_gdb_message)

        # focus on the newly added tab
        self.setCurrentWidget(empty_tab)
        # focus on the query text panel to be able to start typing directly
        empty_tab.query.setFocus()

        if dev_mode:
            empty_tab.gdb = Geodatabase('NYC.gdb')
            empty_tab.connected_gdb_path_label.setText(empty_tab.gdb.path)
            empty_tab._set_gdb_items_highlight()
            empty_tab._fill_toc()
            empty_tab.query.setText('select * from streets limit 1000')
            empty_tab.run_query()
        return
Esempio n. 26
0
    def otvori_tabelu_dete(self):
        if self.central_widget.currentWidget() == None:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Trenutno nijedna datoteka nije otvorena!")
            poruka.exec_()
            return
        elif not hasattr(self.central_widget.currentWidget().table, "selected_elem"):
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Trenutno nijedan element nije selektovan!")
            poruka.exec_()
            return
        elif self.central_widget.currentWidget().tab_widget.currentWidget() == None:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Selektovani element nema podtabele!")
            poruka.exec_()
            return
        elif len(self.central_widget.currentWidget().tab_widget.currentWidget().model.lista_prikaz) == 0:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Selektovani element nema decu u selektovanoj podtabeli!")
            poruka.exec_()
            return

        child = self.central_widget.currentWidget().tab_widget.currentWidget()
        if self.central_widget.currentWidget().is_baza:
            tab = Tab(parent=self.central_widget)
            tab.pocetna_strana = self
            tab.naziv = child.naziv
            indeks = 0
            for i in range(len(self.imena_tabela)):
                if self.imena_tabela[i] == child.naziv:
                    indeks = i
                    break
            for i in range(len(self.lista_baza)):
                if self.lista_baza[i] == self.central_widget.currentWidget().indeks:
                    self.lista_baza.pop(i)
                    break
            tab.indeks = indeks
            # self.lista_baza.append(indeks)
            tab.read(child.putanja)
        else:
            tab = Tab(child.putanja, self.central_widget)
            tab.pocetna_strana = self
            tab.read()
        tab.table.model().lista_prikaz = child.model.lista_prikaz
        
        tab.btn_down.clicked.connect(self.otvori_tabelu_dete)
        tab.btn_up.clicked.connect(self.otvori_tabelu_roditelj)

        self.central_widget.removeTab(self.central_widget.currentIndex())
        self.central_widget.addTab(tab, child.meta_podaci[0])

        meta = ""
        for s in range(len(child.meta_podaci[0])):
            if child.meta_podaci[0][s].isupper():
                meta += "_" + child.meta_podaci[0][s].lower()
            else:
                meta += child.meta_podaci[0][s]
                
        meta = meta[1:len(meta)]
        meta = child.meta_podaci[2] + "\\" + meta
        if child.meta_podaci[1] == "serijska":
            meta += "_ser."
            
        elif child.meta_podaci[1] == "sekvencijalna":
            meta += "_sek."
            
        elif child.meta_podaci[1] == "sql":
            meta += "_meta_podaci_sql."

        meta += child.meta_podaci[3]

        self.lista_putanja.append(meta)
        self.lista_putanja.remove(self.lista_putanja[self.central_widget.currentIndex()])
Esempio n. 27
0
 def __init__(self, tab_option, parent):
     Tab.__init__(self, tab_option)
     self.build_options()
     self.parent = parent
     self.target_decay_rate = 0
Esempio n. 28
0
class TabTest(unittest.TestCase):

    # Method getting the test name
    def getTestName(self):
        testMethodName = re.sub(constants.TEST_NUMBER_PATTERN, constants.EMPTY, self._testMethodName, 1)
        return testMethodName.replace(constants.UNDERSCORE, constants.SPACE)

    # setup method, called once before all the tests
    @classmethod
    def setUpClass(self):

        username = os.getenv(constants.USERNAME,"")
        password = os.getenv(constants.PASSWORD,"")
        """Start web browser"""
        self._home_page = Tab()
        # self._home_page.login_on_page(constants.DERA_SCM_URL, username, password)

    # setup method, called before each test
    def setUp(self):
        time.sleep(2)
        self._home_page.log(constants.STARS_START_LINE)
        self._home_page.log(constants.TEST_START  + self.getTestName())


    def test_0_load_page_in_browser_invalid_url(self):
        with self.assertRaises(Exception) as context:
            url = "derapps-staging.azurewebsites.net/SCM"
            self._home_page.load_page_in_browser(url)

        self.assertTrue('Error Loading URL : {}'.format(url) in context.exception)

    # This will run at end of each test
    def tearDown(self):
        self._home_page.log(constants.TEST_FINSIH  + self.getTestName())
        self.logResult()
        self._home_page.log(constants.STARS_END_LINE)

    # This will run at end of all tests
    @classmethod
    def tearDownClass(self):
        """Logout browser"""
        # try:
        #     time.sleep(2)
        #     self._home_page.logout();
        # except Exception as ex:
        #     self.fail(ex)
        # time.sleep(4)
        self._home_page = None

    # Method to log the result
    def logResult(self):
        if sys.exc_info() == (None, None, None):
            self._home_page.log(constants.TEST_PASS)
        else:
            self._home_page.log(constants.TEST_FAIL)
Esempio n. 29
0
from tab import Tab
from tab import Note
from tab import const

if __name__ == '__main__':
    notes = [
        Note("C3", const.QUARTER),
        Note("D3", const.QUARTER),
        Note("E3", const.QUARTER),
        Note("F3", const.QUARTER),
        Note("G3", const.QUARTER),
        Note("A3", const.QUARTER),
        Note("B3", const.QUARTER),
        Note("C4", const.QUARTER),
        Note("C3", const.QUARTER),
        Note("D3", const.QUARTER),
        Note("E3", const.QUARTER),
        Note("F3", const.QUARTER),
        Note("G3", const.QUARTER),
        Note("A3", const.QUARTER),
        Note("B3", const.QUARTER),
        Note("C4", const.QUARTER)
    ]

    tab = Tab(notes)
    tab.generate()
Esempio n. 30
0
import numpy as np
#from SA import SA
#from HC import HC
from tab import Tab
from GA import GA

#queen = [5,3,2,1,4,0]         Coluna da rainha da linha i.
#                              Nesse exemplo a rainha da linha 0 estaria 
#                              na coluna 5, a rainha da linha 1 na coluna 3
#i x v[i]

if __name__ == '__main__':
    n = 40
    ##---------------------SA-----------------##
    queens = np.arange(0,n)
    tab = Tab(queens)
#    
#    sa = SA(tab,0.000001,4000)
#    aval,tab = sa.run()
#    print('aval=',aval)
#    print(tab)
        
    ga = GA(tab,10,20,0.01)
    pi = ga.populacao_inicial()
    ga.seleciona_individuo_cruzamento()
    ga.crossover()
    
    
    #tabSA = tab.tabuleiro()
    
    ##---------------------HC-----------------##
Esempio n. 31
0
 def crear_tab(self, url, nombre):
     new_tab = Tab(url, nombre)
     self.tabs[nombre] = new_tab
Esempio n. 32
0
    def otvori_tabelu_roditelj(self):
        if self.central_widget.currentWidget() == None:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Trenutno nijedna datoteka nije otvorena!")
            poruka.exec_()
            return
        elif not hasattr(self.central_widget.currentWidget().table, "selected_elem"):
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Trenutno nijedan element nije selektovan!")
            poruka.exec_()
            return

        model = self.central_widget.currentWidget().table.model()
        element_selected = model.get_element(self.central_widget.currentWidget().table.selected_elem)
        veze = []
        veze = self.central_widget.currentWidget().meta_podaci[9].split(",")
        meta_podaci = self.central_widget.currentWidget().meta_podaci
        lista_kljuceva = []
        brojac = len(veze)-1
        lista_roditelja = []

        for i in range(len(veze)):
            if veze[brojac].find("parent_") == -1:
                veze.pop(brojac)
                brojac -= 1
            else:
                lista_roditelja.append(veze[brojac])
                brojac -= 1
        index = -1

        if len(lista_roditelja) == 0:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Selektovani element nema roditelja!")
            poruka.exec_()
            return

        elif len(lista_roditelja) > 1:
            list_tuple = ()
            for i in range(len(lista_roditelja)):
                del1 = lista_roditelja[i].find("_")+1
                del2 = lista_roditelja[i].find("(")
                ime = lista_roditelja[i][del1:del2]

                list_tuple = list_tuple + (ime,)

            input = QtWidgets.QInputDialog.getItem(
                self,
                "Izbor",
                "Trenutna tabela ima vise od 1 roditelja\nIzaberite roditelja:",
                list_tuple,
                0,
                editable=False)
                
            if input[1]:
                for i in range(len(lista_roditelja)):
                    if lista_roditelja[i].find(input[0]) != -1:
                        index = i
                        break
            else:
                return

        elif len(lista_roditelja) == 1:
            index = 0

        if index == -1:
            return
            
        del1 = lista_roditelja[index].find("_")+1
        lista_roditelja[index] = lista_roditelja[index][del1:len(lista_roditelja[index])]
        del1 = lista_roditelja[index].find("(")
        ime_roditelja = lista_roditelja[index][0:del1]
        nova_putanja = ime_roditelja[0].lower()
        
        for s in range(1, len(ime_roditelja)):
            if ime_roditelja[s].isupper():
                nova_putanja += "_" + ime_roditelja[s].lower()
            else:
                nova_putanja += ime_roditelja[s]
                
        
        nova_putanja = meta_podaci[2] + "\\" + nova_putanja
        if meta_podaci[1] == "serijska":
            nova_putanja += "_ser."
            
        elif meta_podaci[1] == "sekvencijalna":
            nova_putanja += "_sek."
            
        elif meta_podaci[1] == "sql":
            nova_putanja += "_meta_podaci_sql."

        nova_putanja += meta_podaci[3]
        
        del1 = lista_roditelja[index].find("(") + 1
        del2 = lista_roditelja[index].find(")")
        lista_kljuceva.append(lista_roditelja[index][del1:del2].split("#"))
        
        if self.central_widget.currentWidget().is_baza:
            tab = Tab(parent=self.central_widget)
            tab.pocetna_strana = self
            tab.naziv = ime_roditelja
            indeks = 0
            for i in range(len(self.imena_tabela)):
                if self.imena_tabela[i] == ime_roditelja:
                    indeks = i
                    break
            for i in range(len(self.lista_baza)):
                if self.lista_baza[i] == self.central_widget.currentWidget().indeks:
                    self.lista_baza.pop(i)
                    break
            tab.indeks = indeks
            tab.read(nova_putanja)
        else:
            tab = Tab(nova_putanja, self.central_widget)
            tab.pocetna_strana = self
            tab.read()

        indeks_roditelja = -1
        for j in range(len(tab.table.model().lista_prikaz)):
            pronadjen = True
            for m in range(len(lista_kljuceva[len(lista_kljuceva)-1])):
                kljucevi = lista_kljuceva[len(lista_kljuceva)-1][m].split("=")
                if len(kljucevi) == 1:
                    if element_selected.__getattribute__(kljucevi[0]) != tab.table.model().lista_prikaz[j].__getattribute__(kljucevi[0]):
                        pronadjen = False
                elif len(kljucevi) == 2:
                    if element_selected.__getattribute__(kljucevi[0]) != tab.table.model().lista_prikaz[j].__getattribute__(kljucevi[1]):
                        pronadjen = False
                else:
                    print("pocetna_strana.py, 124 linija, eror u len(klucevi):", len(kljucevi), "// ", kljucevi)
            if pronadjen:
                indeks_roditelja = j
                break
        
        if indeks_roditelja == -1:
            poruka = QMessageBox()
            icon = QtGui.QIcon("src/ikonice/logo.jpg")
            poruka.setWindowIcon(icon)
            poruka.setWindowTitle("Upozorenje!")
            poruka.setText("Selektovani element nema roditelja sa istim kljucem kao kod selektovanog!")
            poruka.exec_()
            return

        tab.table.selectRow(indeks_roditelja)
        top = tab.table.currentIndex()
        tab.element_selected(top)

        # tab.table.setModel(tab.table.model())

        tab.btn_down.clicked.connect(self.otvori_tabelu_dete)
        tab.btn_up.clicked.connect(self.otvori_tabelu_roditelj)
        # tab.btn_left.clicked.connect(self.otvori_tabelu_levi_rodjak)
        # tab.btn_right.clicked.connect(self.otvori_tabelu_desni_rodjak)

        self.central_widget.removeTab(self.central_widget.currentIndex())
        self.central_widget.addTab(tab, ime_roditelja)

        meta = ""
        for s in range(len(self.central_widget.currentWidget().meta_podaci[0])):
            if self.central_widget.currentWidget().meta_podaci[0][s].isupper():
                meta += "_" + self.central_widget.currentWidget().meta_podaci[0][s].lower()
            else:
                meta += self.central_widget.currentWidget().meta_podaci[0][s]
                
        meta = meta[1:len(meta)]
        meta = self.central_widget.currentWidget().meta_podaci[2] + "\\" + meta
        if self.central_widget.currentWidget().meta_podaci[1] == "serijska":
            meta += "_ser."
            
        elif self.central_widget.currentWidget().meta_podaci[1] == "sekvencijalna":
            meta += "_sek."
            
        elif self.central_widget.currentWidget().meta_podaci[1] == "sql":
            meta += "_meta_podaci_sql."

        meta += self.central_widget.currentWidget().meta_podaci[3]
        
        self.lista_putanja.append(meta)
        self.lista_putanja.remove(self.lista_putanja[self.central_widget.currentIndex()])
Esempio n. 33
0
 def random_tab(self,m):
     queens0 = np.arange(m)
     np.random.shuffle(queens0)
     return Tab(queens0)
Esempio n. 34
0
from tab import Tab

Tab.printDF()
Esempio n. 35
0
    def setUpClass(self):

        username = os.getenv(constants.USERNAME,"")
        password = os.getenv(constants.PASSWORD,"")
        """Start web browser"""
        self._home_page = Tab()