Beispiel #1
0
	def __init__(self, stdscr, wl):
		self.stdscr = stdscr
		self.wl = wl # WindowLogic
		self.cfg = self.wl.cfg
		
		self.lock = thread.allocate_lock()  # Used for concurrent writing by multiple threads
		
		self.screensize_y, self.screensize_x = self.stdscr.getmaxyx();
		height = self.screensize_y-Pad.reservedscreen
		width = self.screensize_x
		
		self.pheight = height
		self.pwidth = width
		self.mypad = curses.newpad(self.pheight+Pad.padbuffersize, self.pwidth)  # @UndefinedVariable
		curses.curs_set(False)  # @UndefinedVariable
		
		self.padr = 0; self.padu = 0; self.padd = 0
		self.mypad.refresh(0, self.padr, self.padu, self.padd, self.pheight, self.pwidth)
		
		# count new lines added by this function for autoscrolling
		(self.pposy, self.pposx) = self.mypad.getyx()
		(self.pmaxy, self.pmaxx) = self.mypad.getmaxyx()
		self.actualpmaxy = self.pmaxy-Pad.padbuffersize
		
		self.tb = Titlebar(self.stdscr, self.wl, self)
		self.sb = Statusbar(self.stdscr, self.wl, self, nickname="(<Pad>)")
		
		self.dlog = self.wl.dlog #DebugLog("debug.log")
		
		self.dlog.msg("pmaxy: " + str(self.pmaxy), 5)
		self.dlog.msg("actualpmaxy: " + str(self.actualpmaxy), 5)
		
		self._active = False # Pad is actively viewed by user
		
		
		self.autoScroll = True
		self.size = 0 # Number of lines in pad
		self.position = 0
		self.line = ''.encode('utf-8')
		self.marked_line = None
		
		self.nickname = ""
Beispiel #2
0
	def __init__(self, root):
		Logo = PhotoImage(file = 'Logo.png') # This will load logo for Quantum IDE
		Font_data = ("calibri", 11) # This Font data will be used to add font to this IDE

		# This will add Title and give Quantum a resolution
		root.title("Quantum")
		root.geometry("1000x675")
		root.iconphoto(False, Logo)

		# These are the global variables
		self.root = root
		self.filename = None

		# This is Text widget in which you can type anything
		self.Text_area = Text(root,
							font = Font_data,
							selectbackground = "#474747",
							insertbackground = "#ff1269",
							foreground = "#f9f9f9",
							background = "#222222",
							undo = True,
							wrap = WORD)

		# This is Scrollbar widget to add a scrollbar in Text widget
		self.scroll = Scrollbar(root, command = self.Text_area.yview)

		# This will configure and pack Text_area and scroll objects
		self.Text_area.configure(yscrollcommand = self.scroll.set)
		self.Text_area.pack(side = LEFT, fill = BOTH, expand = True)
		self.scroll.pack(side = RIGHT, fill = Y)

		# This is a Custom Menu Class in which New and more items are there.
		self.menu = Menubar(self)
		self.status = Statusbar(self)
		self.intellisense = Intellisense(self)
		self.binding_keys()
Beispiel #3
0
    def __init__(self):
        # TODO: Set up proper logging (with the logging module)
        # TODO: Handle window resizing (distributing extra space to columns, probably the columns with treeviews first
        GlobalValues.root = Tkinter.Tk()

        GlobalValues.root.title(
            "Ophidian - MTG Card Searcher and Deck Builder v0.1.1")
        # 'Ophidian'? It's both the larger snake species, an MTG creature and a D&D snake-like monster
        #  Get it? Snake? Python? Anyway the D&D Ophidian turns creatures it bites into Ophidians, and the
        #   Ophidian MTG creature allows you to draw a card if it attacks unopposed. Both are kind of apt
        #   'Ophidian 2350' is also a separate collectible card game though

        # Intercept the 'window close' event, so we can check if there's stuff like unsaved changes before actually closing
        GlobalValues.root.protocol('WM_DELETE_WINDOW', self.onProgramClose)

        GlobalValues.settings = Settings()

        # Set the global data folder to the one from settings
        GlobalValues.carddatafolder = GlobalValues.settings.getSetting(
            'datafolder', os.path.join(GlobalValues.mainfolder, 'data'))

        # Start with the Status Bar, so other parts can use it right away
        GlobalValues.statusbar = Statusbar(GlobalValues.root)
        GlobalValues.statusbar.grid(column=0,
                                    row=5,
                                    columnspan=2,
                                    sticky=Tkinter.W)

        searchEntryFrame = SearchEntryFrame(GlobalValues.root,
                                            width=300,
                                            height=250)
        searchEntryFrame.grid(column=0, row=0, sticky=Tkinter.N)

        GlobalValues.searchResultsFrame = SearchResultsFrame(GlobalValues.root,
                                                             width=300,
                                                             height=400)
        GlobalValues.searchResultsFrame.grid(column=0, row=1)

        GlobalValues.cardDisplayFrame = CardDisplayFrame(GlobalValues.root,
                                                         width=500,
                                                         height=650)
        GlobalValues.cardDisplayFrame.grid(column=1,
                                           row=0,
                                           rowspan=2,
                                           sticky=Tkinter.NW)

        GlobalValues.chosenCardsFrame = ChosenCardsFrame(GlobalValues.root,
                                                         width=350,
                                                         height=600)
        GlobalValues.chosenCardsFrame.grid(column=2,
                                           row=0,
                                           rowspan=2,
                                           sticky=Tkinter.NSEW)

        # Add a checkbox to toggle card image downloading and display, but only if we can actually show images
        if GlobalValues.isImageLibraryLoaded:
            self.showImageCheckbuttonValue = Tkinter.IntVar()
            toggleImageDisplayCheckbox = Tkinter.Checkbutton(
                GlobalValues.root, text="Show Card Images")
            toggleImageDisplayCheckbox.configure(
                variable=self.showImageCheckbuttonValue,
                command=self.toggleShowingImages)
            toggleImageDisplayCheckbox.grid(column=2, row=5, sticky=Tkinter.E)
            if GlobalValues.settings.getSetting('showImages', True):
                toggleImageDisplayCheckbox.select()

        # Check if we need to update the card database
        cardFileDownloader = CardFileDownloader(GlobalValues.root)
        updateResult = cardFileDownloader.handleCardFileUpdate(True)

        # Load the cards
        if not os.path.exists(
                os.path.join(GlobalValues.carddatafolder, 'cards.json')):
            tkMessageBox.showerror(
                "Cardfile not foun",
                "The card database\ncould not be found\n\nPlease try restarting the program\nand letting the updater run",
                parent=GlobalValues.root)
            GlobalValues.root.quit()
        else:
            with open(os.path.join(GlobalValues.carddatafolder, 'cards.json'),
                      'r') as cardfile:
                GlobalValues.cards = json.load(cardfile)

            # Fill out the results list
            GlobalValues.searchResultsFrame.addCards(GlobalValues.cards.keys())

            GlobalValues.root.mainloop()