Changeset 40053
- Timestamp:
- Dec 18, 2009, 9:58:44 PM (15 years ago)
- Location:
- grass/branches/develbranch_6/gui/wxpython
- Files:
-
- 3 edited
-
gui_modules/goutput.py (modified) (18 diffs)
-
gui_modules/prompt.py (modified) (2 diffs)
-
wxgui.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
r40048 r40053 25 25 import threading 26 26 import Queue 27 import shlex 28 import keyword 27 29 28 30 import wx … … 37 39 import preferences 38 40 import menuform 41 import prompt 42 39 43 from debug import Debug as Debug 40 44 from preferences import globalSettings as UserSettings … … 146 150 self.lineWidth = 80 147 151 self.pageid = pageid 152 148 153 # remember position of line begining (used for '\r') 149 154 self.linePos = -1 … … 163 168 self.console_progressbar.Bind(EVT_CMD_PROGRESS, self.OnCmdProgress) 164 169 # abort 165 self.btn_abort = wx.Button( parent=self, id=wx.ID_STOP)170 self.btn_abort = wx.Button(self, -1, "Abort command", size=(125,-1)) 166 171 self.btn_abort.SetToolTipString(_("Abort the running command")) 167 172 self.btn_abort.Bind(wx.EVT_BUTTON, self.OnCmdAbort) … … 180 185 181 186 # 187 # command prompt 188 # 189 self.cmd_prompt = prompt.GPrompt(self, id=wx.ID_ANY) 190 191 # 182 192 # stream redirection 183 193 # … … 193 203 # buttons 194 204 # 195 self.console_clear = wx.Button(parent=self, id=wx.ID_CLEAR) 196 self.console_save = wx.Button(parent=self, id=wx.ID_SAVE) 205 self.console_clear = wx.Button(self, -1, "Clear output", size=(125,-1)) 206 self.cmd_clear = wx.Button(self, -1, "Clear command", size=(125,-1)) 207 self.console_save = wx.Button(self, -1, "Save output", size=(125,-1)) 208 self.Bind(wx.EVT_BUTTON, self.cmd_prompt.OnCmdErase, self.cmd_clear) 197 209 self.Bind(wx.EVT_BUTTON, self.ClearHistory, self.console_clear) 198 210 self.Bind(wx.EVT_BUTTON, self.SaveHistory, self.console_save) … … 205 217 """!Do layout""" 206 218 boxsizer1 = wx.BoxSizer(wx.VERTICAL) 207 gridsizer1 = wx.GridSizer(rows=1, cols=2, vgap=0, hgap=0) 219 gridsizer1 = wx.GridSizer(rows=1, cols=4, vgap=0, hgap=0) 220 208 221 boxsizer1.Add(item=self.cmd_output, proportion=1, 209 flag=wx.EXPAND | wx.ADJUST_MINSIZE, border=0) 222 flag=wx.EXPAND | wx.ALIGN_BOTTOM, border=0) 223 boxsizer1.Add(item=self.cmd_prompt, proportion=0, 224 flag=wx.EXPAND | wx.FIXED_MINSIZE | wx.ALIGN_BOTTOM, border=0) 225 210 226 gridsizer1.Add(item=self.console_clear, proportion=0, 211 flag=wx.ALIGN_CENTER_HORIZONTAL | wx. ADJUST_MINSIZE, border=0)227 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.FIXED_MINSIZE, border=0) 212 228 gridsizer1.Add(item=self.console_save, proportion=0, 213 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, border=0) 214 215 229 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.FIXED_MINSIZE, border=0) 230 gridsizer1.Add(item=self.cmd_clear, proportion=0, 231 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.FIXED_MINSIZE, border=0) 232 gridsizer1.Add(item=self.btn_abort, proportion=0, 233 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.FIXED_MINSIZE, border=0) 216 234 boxsizer1.Add(item=gridsizer1, proportion=0, 217 235 flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL | wx.TOP | wx.BOTTOM, 218 236 border=5) 237 219 238 boxsizer2 = wx.BoxSizer(wx.HORIZONTAL) 220 239 boxsizer2.Add(item=self.console_progressbar, proportion=1, 221 240 flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL) 222 boxsizer2.Add(item=self.btn_abort, proportion=0,223 flag=wx.ALIGN_CENTRE_VERTICAL | wx.LEFT,224 border = 5)225 241 boxsizer1.Add(item=boxsizer2, proportion=0, 226 flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL | wx. ALL,227 border=5)242 flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL | wx.LEFT | wx.RIGHT | 243 wx.TOP, border=5) 228 244 229 245 boxsizer1.Fit(self) … … 233 249 self.SetAutoLayout(True) 234 250 self.SetSizer(boxsizer1) 251 self.Layout() 235 252 236 253 def Redirect(self): … … 270 287 # p1 = self.cmd_output.GetCurrentPos() 271 288 p1 = self.cmd_output.GetEndStyled() 272 self.cmd_output.GotoPos(p1) 289 # self.cmd_output.GotoPos(p1) 290 self.cmd_output.DocumentEnd() 273 291 274 292 for line in text.splitlines(): … … 350 368 except AttributeError: 351 369 pass 352 370 371 # allow writing to output window 372 self.cmd_output.SetReadOnly(False) 373 353 374 if cmdlist[0] in globalvar.grassCmd['all']: 354 375 # send GRASS command without arguments to GUI command interface … … 435 456 # if command is not a GRASS command, treat it like a shell command 436 457 try: 437 #gcmd.Command(cmdlist,438 #stdout=self.cmd_stdout,439 #stderr=self.cmd_stderr)458 # gcmd.Command(cmdlist, 459 # stdout=self.cmd_stdout, 460 # stderr=self.cmd_stderr) 440 461 self.cmdThread.RunCmd(GrassCmd, 441 462 onDone, … … 446 467 except gcmd.CmdError, e: 447 468 print >> sys.stderr, e 469 470 # reset output window to read only 471 self.cmd_output.SetReadOnly(True) 448 472 449 473 return None … … 531 555 else: 532 556 self.cmd_output.AddTextWrapped(message, wrap=None) 533 557 534 558 p2 = self.cmd_output.GetCurrentPos() 535 559 … … 591 615 # set focus on prompt 592 616 if self.parent.GetName() == "LayerManager": 593 self.parent.cmdinput.SetFocus()617 # self.parent.cmdinput.SetFocus() 594 618 self.btn_abort.Enable(False) 595 619 else: … … 757 781 wx.stc.StyledTextCtrl.__init__(self, parent, id) 758 782 self.parent = parent 783 self.SetUndoCollection(True) 784 self.SetReadOnly(True) 759 785 760 786 # … … 763 789 self.SetStyle() 764 790 765 766 791 # 767 792 # line margins … … 787 812 788 813 # 789 # bindin s814 # bindings 790 815 # 791 816 self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) 792 817 793 818 def SetStyle(self): 794 819 """!Set styles for styled text output windows with type face … … 831 856 self.StyleSetSpec(self.StyleWarning, self.StyleWarningSpec) 832 857 self.StyleSetSpec(self.StyleMessage, self.StyleMessageSpec) 833 self.StyleSetSpec(self.StyleUnknown, self.StyleUnknownSpec) 834 858 self.StyleSetSpec(self.StyleUnknown, self.StyleUnknownSpec) 859 835 860 def OnDestroy(self, evt): 836 861 """!The clipboard contents can be preserved after -
grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
r40029 r40053 25 25 26 26 import wx 27 import wx. lib.mixins.listctrl as listmix27 import wx.stc 28 28 29 29 from grass.script import core as grass 30 30 31 31 import globalvar 32 import utils33 import menuform34 32 import menudata 35 36 class GPrompt: 37 """!Interactive GRASS prompt""" 38 def __init__(self, parent): 39 self.parent = parent # GMFrame 40 41 # dictionary of modules (description, keywords, ...) 42 self.modules = self.parent.menudata.GetModules() 43 44 self.panel, self.input = self.__create() 45 46 def __create(self): 47 """!Create widget""" 48 cmdprompt = wx.Panel(self.parent) 49 50 # 51 # search 52 # 53 searchTxt = wx.StaticText(parent = cmdprompt, id = wx.ID_ANY, 54 label = _("Find module:")) 55 56 self.searchBy = wx.Choice(parent = cmdprompt, id = wx.ID_ANY, 57 choices = [_("description"), 58 _("keywords")]) 59 winHeight = self.searchBy.GetSize()[1] 60 61 self.search = wx.TextCtrl(parent = cmdprompt, id = wx.ID_ANY, 62 value = "", size = (-1, 25)) 63 64 label = wx.Button(parent = cmdprompt, id = wx.ID_ANY, 65 label = _("&Cmd >"), size = (-1, winHeight)) 66 label.SetToolTipString(_("Click for erasing command prompt")) 67 68 ### todo: fix TextCtrlAutoComplete to work also on Macs 69 ### reason: missing wx.PopupWindow() 70 try: 71 cmdinput = TextCtrlAutoComplete(parent = cmdprompt, id = wx.ID_ANY, 72 value = "", 73 style = wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER, 74 size = (-1, winHeight), 75 statusbar = self.parent.statusbar) 76 except NotImplementedError: 77 # wx.PopupWindow may be not available in wxMac 78 # see http://trac.wxwidgets.org/ticket/9377 79 cmdinput = wx.TextCtrl(parent = cmdprompt, id = wx.ID_ANY, 80 value = "", 81 style=wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER, 82 size = (-1, 25)) 83 self.searchBy.Enable(False) 84 self.search.Enable(False) 85 86 cmdinput.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, '')) 87 88 wx.CallAfter(cmdinput.SetInsertionPoint, 0) 89 90 # bidnings 91 label.Bind(wx.EVT_BUTTON, self.OnCmdErase) 92 cmdinput.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd) 93 cmdinput.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar) 94 self.search.Bind(wx.EVT_TEXT, self.OnSearchModule) 95 96 # layout 97 sizer = wx.GridBagSizer(hgap=5, vgap=5) 98 sizer.AddGrowableRow(1) 99 sizer.AddGrowableCol(2) 100 101 sizer.Add(item = searchTxt, 102 flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 103 pos = (0, 0)) 104 105 sizer.Add(item = self.searchBy, 106 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER, 107 pos = (0, 1)) 108 109 sizer.Add(item = self.search, 110 flag = wx.EXPAND | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER, 111 border = 5, 112 pos = (0, 2)) 113 114 sizer.Add(item = label, 115 flag = wx.LEFT | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER, 116 border = 5, 117 pos = (1, 0)) 118 119 sizer.Add(item = cmdinput, 120 flag = wx.EXPAND | wx.RIGHT, 121 border = 5, 122 pos = (1, 1), span = (1, 2)) 123 124 cmdprompt.SetSizer(sizer) 125 sizer.Fit(cmdprompt) 126 cmdprompt.Layout() 127 128 return cmdprompt, cmdinput 129 130 def __checkKey(self, text, keywords): 131 """!Check if text is in keywords""" 132 found = 0 133 keys = text.split(',') 134 if len(keys) > 1: # -> multiple keys 135 for k in keys[:-1]: 136 k = k.strip() 137 for key in keywords: 138 if k == key: # full match 139 found += 1 140 break 141 k = keys[-1].strip() 142 for key in keywords: 143 if k in key: # partial match 144 found +=1 33 import gcmd 34 35 class GPrompt(wx.stc.StyledTextCtrl): 36 """!Styled GRASS prompt""" 37 def __init__(self, parent, id, size=wx.DefaultSize, margin=False, wrap=None): 38 wx.stc.StyledTextCtrl.__init__(self, parent, id) 39 self.parent = parent 40 self.SetUndoCollection(True) 41 42 # 43 # styles 44 # 45 self.SetWrapMode(True) 46 47 # 48 # create command and map lists for autocompletion 49 # 50 self.AutoCompSetIgnoreCase(False) 51 52 self.rastlist = [] 53 self.vectlist = [] 54 self.imglist = [] 55 self.r3list = [] 56 self.dblist = [] 57 self.genlist = [] 58 self.displist = [] 59 60 for item in globalvar.grassCmd['all']: 61 if len(item.split('.')) > 1: 62 start,end = item.split('.',1) 63 if start == 'r': self.rastlist.append(end) 64 elif start == 'v': self.vectlist.append(end) 65 elif start == 'i': self.imglist.append(end) 66 elif start == 'r3': self.r3list.append(end) 67 elif start == 'db': self.dblist.append(end) 68 elif start == 'g': self.genlist.append(end) 69 elif start == 'd': self.displist.append(end) 70 71 self.rastlist.sort() 72 self.vectlist.sort() 73 self.imglist.sort() 74 self.r3list.sort() 75 self.dblist.sort() 76 self.genlist.sort() 77 self.displist.sort() 78 79 self.datatypes = [] 80 self.maplists = {} 81 self.maptype = '' 82 self.datatypes = ['rast', 83 'rast3d', 84 'vect', 85 'oldvect', 86 'asciivect', 87 'labels', 88 'region', 89 'region3d', 90 'group', 91 '3dview'] 92 93 self.drastcmd = ['d.rast', 94 'd.rgb', 95 'd.his', 96 'd.rast.arrow', 97 'd.rast.num'] 98 99 self.dvectcmd = ['d.vect', 100 'd.vect.chart' 101 'd.thematic.area', 102 'd.vect.thematic'] 103 104 self.rastargs = ['map', 105 'input', 106 'elevation', 107 'color', 108 'rast', 109 'raster', 110 'red', 111 'green', 112 'blue', 113 'h_map', 114 'i_map', 115 's_map', 116 'hue_input', 117 'intensity_input', 118 'saturation_input', 119 'red_input', 120 'green_input', 121 'blue_input'] 122 123 self.__getfiles() 124 125 # 126 # command history buffer 127 # 128 self.cmdbuffer = [] 129 self.cmdindex = 0 130 131 # 132 # line margins 133 # 134 # TODO print number only from cmdlog 135 self.SetMarginWidth(1, 0) 136 self.SetMarginWidth(2, 0) 137 if margin: 138 self.SetMarginType(0, wx.stc.STC_MARGIN_NUMBER) 139 self.SetMarginWidth(0, 30) 140 else: 141 self.SetMarginWidth(0, 0) 142 143 # 144 # miscellaneous 145 # 146 self.SetViewWhiteSpace(False) 147 # self.SetTabWidth(4) 148 self.SetUseTabs(False) 149 self.UsePopUp(True) 150 self.SetSelBackground(True, "#FFFF00") 151 self.SetUseHorizontalScrollBar(True) 152 153 # 154 # bindings 155 # 156 self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) 157 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed) 158 159 def __getfiles(self): 160 for item in self.datatypes: 161 mlist = grass.read_command("g.mlist", "m", type=item).splitlines() 162 mlist.sort() 163 self.maplists[item] = mlist 164 165 def OnKeyPressed(self, event): 166 """!Key press capture for autocompletion, tooltips, and command history""" 167 #keycodes used: "." = 46, "=" = 61, "," = 44 168 line = '' 169 entry = '' 170 usage = '' 171 cmdtype = '' 172 cmdname = '' 173 cmd = '' 174 if event.GetKeyCode() != 44: 175 self.maptype = '' 176 177 # CAN CHANGE: event.ControlDown() for manual autocomplete 178 179 if event.GetKeyCode() == 46 and not event.ShiftDown(): 180 #GRASS command autocomplete when "." is pressed after r,v,i,g,db, or d 181 listcmds = [] 182 pos = self.GetCurrentPos() 183 self.InsertText(pos,'.') 184 self.CharRight() 185 186 entry = self.GetTextLeft() 187 if entry not in ['r.','v.','i.','g.','db.','d.']: 188 return 189 190 if entry == 'r.': listcmds = self.rastlist 191 elif entry == 'v.': listcmds = self.vectlist 192 elif entry == 'i.': listcmds = self.imglist 193 elif entry == 'r3.': listcmds = self.r3list 194 elif entry == 'db.': listcmds = self.dblist 195 elif entry == 'g.': listcmds = self.genlist 196 elif entry == 'd.': listcmds = self.displist 197 198 if listcmds == []: 199 return 200 else: 201 self.AutoCompShow(0, " ".join(listcmds)) 202 203 elif event.GetKeyCode() == wx.WXK_TAB: 204 #GRASS command calltips 205 206 #Must be a command to the left somewhere 207 pos = self.GetCurrentPos() 208 entry = self.GetTextLeft() 209 cmd = entry.split()[0].strip() 210 if cmd not in globalvar.grassCmd['all']: 211 return 212 213 usage, description = self.GetCommandUsage(cmd) 214 215 self.CallTipSetBackground("PALE GREEN") 216 self.CallTipSetForeground("BLACK") 217 self.CallTipShow(pos, usage+'\n\n'+description) 218 219 elif (event.GetKeyCode() == wx.WXK_SPACE and event.ControlDown()) or \ 220 event.GetKeyCode() == 61 or event.GetKeyCode() == 44: 221 #Autocompletion for map/data file name entry 222 pos = self.GetCurrentPos() 223 entry = self.GetTextLeft() 224 arg = '' 225 226 if entry.strip()[0:2] in ['r.','v.','i.','g.','db.','d.']: 227 cmdtype = entry.strip()[0] 228 cmd = entry.split()[0].strip() 229 if cmd in globalvar.grassCmd['all']: 230 cmdname = cmd.split('.')[1] 231 else: 232 #No complete GRASS command found 233 cmd = '' 234 cmdname = '' 235 elif entry.strip()[0:4] == 'nviz': 236 cmdtype = '' 237 cmdname = cmd = 'nviz' 238 else: 239 #No partial or complete GRASS command found 240 return 241 242 cmdargs = entry.strip('=') 243 try: 244 arg = cmdargs.rsplit(' ',1)[1] 245 except: 246 arg = '' 247 248 if event.GetKeyCode() == 61: 249 #insert the '=' and move to the end of the line, ready for a map name 250 self.InsertText(pos,'=') 251 self.CharRight() 252 253 maplist = [] 254 maptype = '' 255 256 #what kind of map/data type is desired? 257 if (((cmdtype in ['r', 'i'] or cmd in self.drastcmd) and arg in self.rastargs) or 258 ((cmd=='nviz' or cmdtype=='r3') and (arg=='elevation' or arg=='color')) or 259 arg=='rast' or arg=='raster'): 260 self.maptype = 'rast' 261 elif (((cmdtype=='v' or cmd in self.dvectcmd) and arg in ['map', 'input']) or 262 (cmdtype=='r3' and arg=='input') or 263 arg in ['vect', 'vector', 'points']): 264 self.maptype = 'vect' 265 elif ((cmdtype=='r3' and (arg=='map' or arg=='input')) or 266 (cmdtype=='nviz' and arg=='volume') or arg=='rast3d'): 267 self.maptype = 'rast3d' 268 elif arg=='labels': 269 self.maptype ='labels' 270 elif arg=='region': 271 self.maptype ='region' 272 elif arg=='region3d': 273 self.maptype ='region3d' 274 elif arg=='group': 275 self.maptype ='group' 276 elif arg=='3dview': 277 self.maptype ='3dview' 278 279 elif event.GetKeyCode() == 44: 280 #if ctrl-comma is pressed, use the same maptype as previous for multiple map entries 281 282 # insert the comma and move to the end of the line ready for a map name 283 self.InsertText(pos,',') 284 self.CharRight() 285 286 #must apply to an entry where '=[string]' has already been entered 287 if '=' not in arg: 288 return 289 290 elif event.GetKeyCode() == wx.WXK_SPACE and event.ControlDown(): 291 #map entries without arguments (as in r.info [mapname]) use ctrl-shift 292 maplist = [] 293 if cmdtype=='r' or cmdtype=='i': 294 self.maptype = 'rast' 295 elif cmdtype=='v': 296 self.maptype = 'vect' 297 elif cmdtype=='r3': 298 self.maptype = 'rast3d' 299 300 if self.maptype == '': 301 return 302 else: 303 maplist = self.maplists[self.maptype] 304 self.AutoCompShow(0, " ".join(maplist)) 305 306 elif event.GetKeyCode() in [wx.WXK_UP,wx.WXK_DOWN] and event.ControlDown(): 307 #Command history 308 309 if self.cmdbuffer == []: return 310 txt = '' 311 312 self.DocumentEnd() 313 314 if event.GetKeyCode() == wx.WXK_UP: 315 self.cmdindex = self.cmdindex - 1 316 if event.GetKeyCode() == wx.WXK_DOWN: 317 self.cmdindex = self.cmdindex + 1 318 if self.cmdindex < 0: 319 self.cmdindex = 0 320 if self.cmdindex > len(self.cmdbuffer) - 1: 321 self.cmdindex = len(self.cmdbuffer) - 1 322 323 try: 324 txt = self.cmdbuffer[self.cmdindex] 325 except: 326 pass 327 328 self.DelLineLeft() 329 self.DelLineRight() 330 pos = self.GetCurrentPos() 331 self.InsertText(pos,txt) 332 self.LineEnd() 333 334 elif event.GetKeyCode() == wx.WXK_RETURN and self.AutoCompActive() == False: 335 #Run command on line when <return> is pressed 336 print 'in command' 337 #find the command to run 338 line = str(self.GetCurLine()[0]).strip() 339 if len(line) == 0: 340 return 341 342 cmd = shlex.split(str(line)) 343 344 #send the command to the processor 345 self.parent.RunCmd(cmd) 346 347 #add command to buffer 348 self.cmdbuffer.append(line) 349 350 #keep buffer to a managable size 351 if len(self.cmdbuffer) > 200: 352 del self.cmdbuffer[0] 353 self.cmdindex = len(self.cmdbuffer) 354 355 else: 356 event.Skip() 357 358 def GetTextLeft(self): 359 """!Returns all text left of the caret""" 360 entry = '' 361 pos = self.GetCurrentPos() 362 self.HomeExtend() 363 entry = self.GetSelectedText().strip() 364 self.SetCurrentPos(pos) 365 366 return entry 367 368 def GetCommandUsage(self, command): 369 """!Returns the usage information for a command""" 370 usage = '' 371 description = '' 372 373 ret, out = gcmd.RunCommand(command, 'help', getErrorMsg = True) 374 375 if ret == 0: 376 cmdhelp = out.splitlines() 377 addline = False 378 helplist = [] 379 description = '' 380 for line in cmdhelp: 381 if "Usage:" in line: 382 addline = True 383 continue 384 elif "Flags:" in line: 385 addline = False 145 386 break 387 elif addline == True: 388 line = line.strip() 389 helplist.append(line) 390 391 for line in cmdhelp: 392 if "Description:" in line: 393 addline = True 394 continue 395 elif "Keywords:" in line: 396 addline = False 397 break 398 elif addline == True: 399 description += (line + ' ') 400 401 description = description.strip() 402 403 for line in helplist: 404 usage += line + '\n' 405 406 return usage.strip(), description 146 407 else: 147 for key in keywords: 148 if text in key: # partial match 149 found +=1 150 break 151 152 if found == len(keys): 153 return True 154 155 return False 156 157 def GetPanel(self): 158 """!Get main widget panel""" 159 return self.panel 160 161 def GetInput(self): 162 """!Get main prompt widget""" 163 return self.input 408 return '' 409 410 def OnDestroy(self, evt): 411 """!The clipboard contents can be preserved after 412 the app has exited""" 413 414 wx.TheClipboard.Flush() 415 evt.Skip() 164 416 165 417 def OnCmdErase(self, event): 166 418 """!Erase command prompt""" 167 self.input.SetValue('') 419 self.Home() 420 self.DelLineRight() 168 421 169 422 def OnRunCmd(self, event): … … 665 918 666 919 event.Skip() 920 >>>>>>> .r40052 -
grass/branches/develbranch_6/gui/wxpython/wxgui.py
r40048 r40053 1 """ !1 """ 2 2 @package wxgui.py 3 3 … … 120 120 self.curr_page = '' # currently selected page for layer tree notebook 121 121 self.curr_pagenum = '' # currently selected page number for layer tree notebook 122 self.encoding = 'ISO-8859-1' # default encoding for display fonts 122 123 self.workspaceFile = workspace # workspace file 123 124 self.menucmd = dict() # menuId / cmd 124 125 self.georectifying = None # reference to GCP class or None 126 125 127 # list of open dialogs 126 128 self.dialogs = dict() … … 129 131 130 132 # creating widgets 131 # -> self.notebook, self.goutput, self.outpage132 133 self.notebook = self.__createNoteBook() 133 134 self.menubar, self.menudata = self.__createMenuBar() 134 135 self.statusbar = self.CreateStatusBar(number=1) 135 self.cmdprompt, self.cmdinput = self.__createCommandPrompt()136 136 self.toolbar = self.__createToolBar() 137 137 … … 147 147 Left().CentrePane().BestSize((-1,-1)).Dockable(False). 148 148 CloseButton(False).DestroyOnClose(True).Row(1).Layer(0)) 149 self._auimgr.AddPane(self.cmdprompt, wx.aui.AuiPaneInfo().150 Bottom().BestSize((-1, -1)).Dockable(False).151 CloseButton(False).DestroyOnClose(True).152 PaneBorder(False).Row(1).Layer(0).Position(0).153 CaptionVisible(False))154 149 155 150 self._auimgr.Update() 156 151 157 152 wx.CallAfter(self.notebook.SetSelection, 0) 158 wx.CallAfter(self. cmdinput.SetFocus)153 wx.CallAfter(self.goutput.cmd_prompt.SetFocus) 159 154 160 155 # use default window layout ? … … 193 188 self.curr_page.maptree.mapdisplay.Raise() 194 189 self.Raise() 195 196 def __createCommandPrompt(self): 197 """!Creates command-line input area""" 198 p = prompt.GPrompt(self) 199 200 return p.GetPanel(), p.GetInput() 201 190 202 191 def __createMenuBar(self): 203 192 """!Creates menubar""" … … 368 357 if page == self.goutput.pageid: 369 358 # remove '(...)' 370 self.notebook.SetPageText(page, _("Command output"))359 self.notebook.SetPageText(page, _("Command console")) 371 360 372 361 event.Skip() … … 455 444 cmd = self.GetMenuCmd(event) 456 445 self.goutput.RunCmd(cmd, switchPage=True) 457 446 458 447 def OnMenuCmd(self, event, cmd = ''): 459 448 """!Parse command selected from menu""" … … 549 538 """!Display 'About GRASS' dialog""" 550 539 win = AboutWindow(self) 551 win.Centre OnScreen()540 win.Centre() 552 541 win.Show(True) 553 542 … … 980 969 gisbase = os.environ['GISBASE'] 981 970 982 if sys.platform == win32:971 if 'OS' in os.environ and os.environ['OS'] == "Windows_NT": 983 972 runbat = os.path.join(gisbase,'etc','grass-run.bat') 984 973 cmdlist = ["cmd.exe", "/c", 'start "%s"' % runbat, command] … … 1542 1531 1543 1532 def OnQuit(self, event): 1544 """!Quit GRASS session (wxGUI and shell)"""1533 """!Quit GRASS""" 1545 1534 # quit wxGUI session 1546 1535 self.OnCloseWindow(event) 1547 1536 1548 1537 # quit GRASS shell 1549 1538 try: 1550 pid = int(os.environ['GIS_LOCK']) 1551 except (KeyError, ValueError): 1552 sys.stderr.write('\n') 1553 sys.stderr.write(_("WARNING: Unable to quit GRASS, uknown GIS_LOCK")) 1539 pid = os.environ['GRASS_SHELL_PID'] 1540 except KeyError: 1554 1541 return 1555 1556 os.kill( pid, signal.SIGQUIT)1542 1543 os.kill(int(pid), signal.SIGQUIT) 1557 1544 1558 1545 def OnCloseWindow(self, event):
Note:
See TracChangeset
for help on using the changeset viewer.
