Ejemplo n.º 1
0
Archivo: nett.py Proyecto: EluOne/Nett
    def OnExport(self, event):
        # Export the contents of the Quickbar as csv.
        if quickbarList != []:
            self.dirname = ''
            wildcard = "Comma Separated (*.csv)|*.csv|All files (*.*)|*.*"
            dlg = wx.FileDialog(self, 'Export Price Data to File', self.dirname, 'export.csv', wildcard, wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                f = file(path, 'w')
                """ Item(itemID, itemName, marketGroupID,
                         amarrItemBuy, dodixieItemBuy, hekItemBuy, jitaItemBuy,
                         amarrItemSell, dodixieItemSell, hekItemSell, jitaItemSell,
                         reproAmarrBuy, reproDodixieBuy, reproHekBuy, reproJitaBuy,
                         reproAmarrSell, reproDodixieSell, reproHekSell, reproJitaSell)"""
                columns = ('Item Name', 'Amarr Market Buy Orders', 'Amarr Market Sell Orders', 'Amarr Material Buy Orders', 'Amarr Material Sell Orders',
                           'Dodixie Market Buy Orders', 'Dodixie Market Sell Orders', 'Dodixie Material Buy Orders', 'Dodixie Material Sell Orders',
                           'Hek Market Buy Orders', 'Hek Market Sell Orders', 'Hek Material Buy Orders', 'Hek Material Sell Orders',
                           'Jita Market Buy Orders', 'Jita Market Sell Orders', 'Jita Material Buy Orders', 'Jita Material Sell Orders')

                dataExport = ('%s%s' % (','.join(columns), '\n'))
                for row in quickbarList:
                    dataExport = ('%s%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n' % (dataExport, row.itemName,
                                                                                              row.amarrItemBuy, row.amarrItemSell, row.reproAmarrBuy, row.reproAmarrSell,
                                                                                              row.dodixieItemBuy, row.dodixieItemSell, row.reproDodixieBuy, row.reproDodixieSell,
                                                                                              row.hekItemBuy, row.hekItemSell, row.reproHekBuy, row.reproHekSell,
                                                                                              row.jitaItemBuy, row.jitaItemSell, row.reproJitaBuy, row.reproJitaSell))
                f.write(dataExport)
                f.close()
            dlg.Destroy()
        else:
            onError('The Quickbar list is empty. There is no data to export yet.')
Ejemplo n.º 2
0
Archivo: nett.py Proyecto: EluOne/Nett
    def searchTree(self, event):
        searchText = self.searchTextCtrl.GetValue()

        # Reset the itemList and marketRelations
        del itemList[:]
        marketRelations.clear()

        itemMarketGroups = []

        # List and Dictionary initialisation.
        if itemList == []:  # Build a list of all items from the static data dump.
            try:
                con = lite.connect('static.db')  # A cut down version of the CCP dump converted to sqlite. (~8mb)
                con.text_factory = str

                with con:
                    cur = con.cursor()
                    # With this query we are looking to populate the itemID's with their respective names and parent market groups.
                    # Eve items currently go up to ID 33612, then Dust items start from 350916
                    statement = "SELECT typeID, typeName, marketGroupID FROM invtypes WHERE marketGroupID >= 0 AND typeName LIKE '%" + searchText + "%' ORDER BY typeName;"
                    cur.execute(statement)

                    rows = cur.fetchall()

                    for row in rows:
                        # The data above taken from the db then all zeros for the buy/sell values (x16), query time and widget key.
                        itemList.append(Item(int(row[0]), str(row[1]), int(row[2]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
                        itemMarketGroups.append(int(row[2]))

                    # Iterate over the relations to build all the relavent branches.
                    while itemMarketGroups != []:
                        # This statement is for the branches of the market treeCtrl using all the market groups and their relationship to each other.
                        itemMarketList = ("', '".join(map(str, itemMarketGroups[:])))
                        relationStatement = ("SELECT marketGroupID, parentGroupID FROM invMarketGroups WHERE marketGroupID IN ('%s') ORDER BY parentGroupID;" % itemMarketList)
                        cur.execute(relationStatement)

                        relationRows = cur.fetchall()

                        itemMarketGroups = []

                        for row in relationRows:
                            if row[1]:
                                marketRelations.update({int(row[0]): int(row[1])})
                                itemMarketGroups.append(int(row[1]))
                            else:
                                marketRelations.update({int(row[0]): 'Market'})

            except lite.Error as err:
                error = ('SQL Lite Error: ' + repr(err.args[0]) + repr(err.args[1:]))  # Error String
                onError(error)
            finally:
                if con:
                    con.close()

        # Reinitialize the marketTree
        self.marketTree.DeleteAllItems()
        self.buildTree('Market')
Ejemplo n.º 3
0
Archivo: nett.py Proyecto: EluOne/Nett
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        self.numWidgets = 0

        # List and Dictionary initialisation.
        if itemList == []:  # Build a list of all items from the static data dump.
            try:
                con = lite.connect('static.db')  # A cut down version of the CCP dump converted to sqlite. (~8mb)
                con.text_factory = str

                with con:
                    cur = con.cursor()
                    # With this query we are looking to populate the itemID's with their respective names and parent market groups.
                    # Eve items currently go up to ID 33612, then Dust items start from 350916
                    statement = "SELECT typeID, typeName, marketGroupID FROM invtypes WHERE marketGroupID >= 0 ORDER BY typeName;"
                    cur.execute(statement)

                    rows = cur.fetchall()

                    for row in rows:
                        # The data above taken from the db then all zeros for the buy/sell values (x16), query time and widget key.
                        itemList.append(Item(int(row[0]), str(row[1]), int(row[2]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

                    # This query will hold all of the market group ID to name relations in a dictionary for ease.
                    groupStatement = "SELECT marketGroupID, marketGroupName FROM invMarketGroups WHERE marketGroupID >= 0 ORDER BY marketGroupID;"
                    cur.execute(groupStatement)

                    groupRows = cur.fetchall()

                    for row in groupRows:
                        marketGroups.update({int(row[0]): str(row[1])})

                    # This statement is for the branches of the market treeCtrl using all the market groups and their relationship to each other.
                    relationStatement = "SELECT marketGroupID, parentGroupID FROM invMarketGroups ORDER BY parentGroupID;"
                    cur.execute(relationStatement)

                    relationRows = cur.fetchall()

                    for row in relationRows:
                        if row[1]:
                            marketRelations.update({int(row[0]): int(row[1])})
                        else:
                            marketRelations.update({int(row[0]): 'Market'})

            except lite.Error as err:
                error = ('SQL Lite Error: ' + repr(err.args[0]) + repr(err.args[1:]))  # Error String
                onError(error)
            finally:
                if con:
                    con.close()

        self.leftNotebook = wx.Notebook(self, wx.ID_ANY, style=0)
        self.marketNotebookPane = wx.Panel(self.leftNotebook, wx.ID_ANY)
        self.searchTextCtrl = wx.TextCtrl(self.marketNotebookPane, wx.ID_ANY, "")
        self.searchButton = wx.Button(self.marketNotebookPane, wx.ID_FIND, (""))
        self.marketTree = wx.TreeCtrl(self.marketNotebookPane, wx.ID_ANY, style=wx.TR_HAS_BUTTONS | wx.TR_DEFAULT_STYLE | wx.SUNKEN_BORDER)
        self.addButton = wx.Button(self.marketNotebookPane, wx.ID_ANY, ("Add to Quickbar"))
        self.fetchButton = wx.Button(self.marketNotebookPane, wx.ID_ANY, ("Fetch Data"))

        self.quickbarNotebookPane = wx.Panel(self.leftNotebook, wx.ID_ANY)
        self.quickbarListCtrl = ObjectListView(self.quickbarNotebookPane, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.removeButton = wx.Button(self.quickbarNotebookPane, wx.ID_ANY, ("Remove From Quickbar"))
        self.fetchButtonTwo = wx.Button(self.quickbarNotebookPane, wx.ID_ANY, ("Fetch Data"))

        self.materiallsNotebookPane = wx.Panel(self.leftNotebook, wx.ID_ANY)
        self.materialsListCtrl = GroupListView(self.materiallsNotebookPane, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        self.rightPanel = wx.ScrolledWindow(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL)

        self.statusbar = self.CreateStatusBar()  # A Status bar in the bottom of the window

        # Menu Bar
        self.frame_menubar = wx.MenuBar()

        self.fileMenu = wx.Menu()
        self.menuAbout = wx.MenuItem(self.fileMenu, wx.ID_ABOUT, "&About", "", wx.ITEM_NORMAL)
        self.fileMenu.AppendItem(self.menuAbout)

        self.menuExport = wx.MenuItem(self.fileMenu, wx.ID_SAVE, "&Export", " Export Price Data", wx.ITEM_NORMAL)
        self.fileMenu.AppendItem(self.menuExport)

        self.menuExit = wx.MenuItem(self.fileMenu, wx.ID_EXIT, "E&xit", "", wx.ITEM_NORMAL)
        self.fileMenu.AppendItem(self.menuExit)

        self.frame_menubar.Append(self.fileMenu, "File")
        self.SetMenuBar(self.frame_menubar)
        # Menu Bar end

        # Menu events.
        self.Bind(wx.EVT_MENU, self.OnExport, self.menuExport)
        self.Bind(wx.EVT_MENU, self.OnExit, self.menuExit)
        self.Bind(wx.EVT_MENU, self.OnAbout, self.menuAbout)

        # Button Events
        self.Bind(wx.EVT_BUTTON, self.onProcess, self.fetchButton)
        self.Bind(wx.EVT_BUTTON, self.onProcess, self.fetchButtonTwo)

        self.Bind(wx.EVT_BUTTON, self.onAdd, self.addButton)
        self.Bind(wx.EVT_BUTTON, self.onRemove, self.removeButton)

        self.Bind(wx.EVT_BUTTON, self.searchTree, self.searchButton)

        # register the self.onExpand function to be called
        wx.EVT_TREE_ITEM_EXPANDING(self.marketTree, self.marketTree.GetId(), self.onExpand)

        self.__set_properties()
        self.__do_layout()