Пример #1
0
    def drawItem(self, x, y, name, group, **kw):
        # Get the item
        try:
            item = self.optionsDict[name]
        except KeyError:
            item = self.optionsDict[name] = Tk_VDB.getCanvasObject(
                self.Map, name, group)
##  	    print "Item", name, item
        if item is None:
            # Item known to be invalid
            return
        # Convert the internal coords to screen locations
        coords = item[1]
        l = len(coords) / 2
        coords = map(
            operator.add, (x, y) * l,
            map(operator.mul,
                (self.gridsize[0], self.gridsize[1] * 2.0 / 3.0) * l, coords))

        # QUICK FIX FOR UBUNTU 15.10
        # Author: vano101 freelancer
        if 'fill' in item[2]:
            if item[2]['fill'] == ' ' or item[2]['fill'] == '':
                item[2]['fill'] = ''

        dict = {}
        dict.update(item[2])
        dict.update(kw)
        # Draw it
        return apply(item[0], tuple(coords), dict)
Пример #2
0
    def drawItem(self, x, y, name, group, **kw):
        # Get the item
        try:
            item = self.optionsDict[name]
        except KeyError:
            item = self.optionsDict[name] = Tk_VDB.getCanvasObject(
                self.Map, name, group)
##  	    print "Item", name, item
        if item is None:
            # Item known to be invalid
            return
        # Convert the internal coords to screen locations
        coords = item[1]
        l = len(coords)/2
        coords = map(operator.add, (x, y)*l, map(
            operator.mul, (self.gridsize[0], self.gridsize[1]*2.0/3.0)*l,
            coords))
        dict = {}
        dict.update(item[2])
        dict.update(kw)
        # Draw it
        return apply(item[0], tuple(coords), dict)
Пример #3
0
    def __init__(self):
        global viewer
        MapWin.viewer = CenWin.viewer = LoginWin.viewer = \
                        TeleWin.viewer = OutWin.viewer = \
                        viewer = self

        # Setup the balloon help.
        self.Balloon = Pmw.Balloon(Display)

        self.msgQueue = []
        self.stsList = []
        self.updateList = []
        self.atPrompt = 0

        self.Root = Display
        self.Root.title("Python/Tk Empire Interface")

        self.coord = Tkinter.StringVar()

        statusbar = Tkinter.Frame(self.Root, name="statusbar")
        statusbar.pack(side='bottom', anchor='s', fill='both')
        coordLabel = Tkinter.Label(self.Root, name="coord",
                                   textvariable=self.coord, width=20,
                                   relief="sunken")
        coordLabel.pack(in_=statusbar, fill='both', side='right')
        self.Balloon.bind(coordLabel, "Empire coordinates")
        self.queueStatus = LoginWin.QueueStatus(statusbar)

        self.Status = Tkinter.Entry(self.Root, name="status", relief='sunken')
        self.Status.pack(in_=statusbar, fill='both', expand=1)
        self.Status.bind('<Key-Return>', self.DoStatus)
        self.Status.insert(0, "Welcome to empire!")
        self.Status['state']='disabled'

##  	# Create a main PanedWidget with top and bottom panes.
##  	pane = Pmw.PanedWidget(self.Root, hull_width='7i', hull_height=800)
##  	pane.pack(side='right', expand=1, fill='both')

        mapframe = Tkinter.Frame(self.Root, name="mapframe", class_="Map")
##  	mapframe = Tkinter.Frame(self.Root, name="mapframe", class_="Map")
##  	mapframe.pack(in_=pane.add('top'), expand=1, fill='both')
##  	mapframe = Tkinter.Frame(pane.pane('top'), name="mapframe", class_="Map")
##  	mapframe.pack(expand=1, fill='both')
##  	mapframe = pane.add('mapframe')

        self.map = MapWin.mapSubWin(mapframe)
        self.mapList = [self.map]

        infoframe = Tkinter.Frame(self.Root, name="infoframe")
        infoframe.pack(side='left', fill='both')
        self.CmdPrompt = Tkinter.Label(self.Root, name="cmdprompt",
                                       anchor='ne')
        self.CmdPrompt.pack(in_=infoframe, side='bottom', anchor='s',
                            fill='x')
        self.CmdPrompt.bind('<Configure>',
                            (lambda e, cp=self.CmdPrompt:
                             cp.configure({'wraplength': e.width})))
        self.Balloon.bind(self.CmdPrompt, "Empire prompt")
        self.cen = CenWin.cenWin(infoframe)

        ioframe = Tkinter.Frame(self.Root, name="ioframe", class_="Censor")
##  	ioframe.pack(in_=pane.add('bottom', size=400), expand=1, fill='both')
##  	ioframe = Tkinter.Frame(pane.pane('bottom'), name="ioframe",
##  				class_="Censor")
##  	ioframe.pack(expand=1, fill='both')
##  	ioframe = pane.add('ioframe')

        self.Prompt = Tkinter.Entry(self.Root, name="prompt")
        self.Prompt.pack(in_=ioframe, side='bottom', anchor='s', fill='x')
        self.Prompt.bind('<Key-Return>', self.DoCmd)
        self.Prompt.bind('<Control-z>', self.DoCtld)
        self.Prompt.bind('<Up>', (lambda e, s=self: s.DoHistoryMove(1)))
        self.Prompt.bind('<Down>', (lambda e, s=self: s.DoHistoryMove(-1)))
        self.Prompt.focus()

        scrollY = Tkinter.Scrollbar(self.Root, name="ioscrollbar")
        scrollY.pack(in_=ioframe, side='right', anchor='e', fill='y')
        self.Output = MyText.MyText(self.Root, name="iobox",
                                    yscrollcommand=scrollY.set,
                                    next = self.Prompt)
        self.Output.setEditable(0)
        self.Output.pack(in_=ioframe, side='left', anchor='se',
                         expand=1, fill='both')
##  	scrollY = Tkinter.Scrollbar(ioframe, name="ioscrollbar")
##  	scrollY.pack(side='right', anchor='e', fill='y')
##  	self.Output = Tkinter.Text(ioframe, name="iobox", state='disabled',
##  				   yscrollcommand=scrollY.set)
##  	self.Output.pack(side='left', anchor='se',
##  			 expand=1, fill='both')
        scrollY['command'] = self.Output.yview
        self.Output.bind('<Button-3>', self.DoLocateSector)
        self.Output.bind('<Configure>', (lambda e, s=self.Output:
                                         s.see('end')))
##  	# Windows hack!
##  	bindFocus(self.Output)

        pane = Tk_Pane.paned(self.Root, mapframe, ioframe)
        self.Balloon.bind(pane.Grip, "Resize window")

        self.Root.bind('<Prior>',
                       (lambda e, s=self.Output:
                        s.yview('scroll', -1, 'page')))
        self.Root.bind('<Next>',
                       (lambda e, s=self.Output:
                        s.yview('scroll', 1, 'page')))
        self.Root.bind('<Tab>',
                       (lambda e, s=self:
                        s.insertText(s.cen.getKey()) or "break"))
        self.Root.bind('<Alt-Key>', self.DoAltHandler)

        # Establish default bindings for text prompts
        Tk_VDB.setTextOptions(self.Output,
                              ('data', 'prompt', 'command', 'flush',
                               'subcommand', 'flash', 'inverse', 'error'))
##	self.lwrite(('data', 'data'), "\n", ('prompt :', 'prompt'),
##		    ('command', 'command'), "\n",
##		    ('subprompt :', 'subprompt'),
##		    ('subcommand', 'subcommand'), "\n", ('flash', 'flash'))

        self.loginCallback = LoginWin.loginWin()
        self.telegramWindow = TeleWin.teleWin()
        self.Root.update_idletasks()
        self.Root.pack_propagate(0)
        infoframe.pack_propagate(0)
        InitFileHandler()