示例#1
0
def startFLTKMainLoop():
  """
This function will start the fltk main loop. It allows to use pyvisus
from python in a standalone fashion. Note that this function will only
return once all pyvisus windows are closed. Furthermore, the mainloop
must be run from the main thread of the program as it will not process
events correctly when running in a child process.
"""
  
  gVisusGuiMaster.mainLoop()
  return

  if gui_support.root_exists():      
    gui_support.root().mainloop()
  else: 
    gVisusGuiMaster.mainLoop()
示例#2
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, t_name='default',o_name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas

        self.text=self.canvas.gettext(t_name,o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error '+t_name+' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error '+o_name+' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent=Parent
        try:
            self.parent_Name=self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color
        
#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
#        if self.gui_parent is None:
#            self.gui_parent=Tkinter.Toplevel()
#            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
#            self.gui_parent.withdraw()
#################################################################################################

        title='Text Editor - table: '+self.text.Tt_name+', orientation: '+self.text.To_name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Text Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open textobject file',
                         label = 'Open TextObject File',
                         command = gui_control.Command( self.evt_open_file, master ),
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
##                                     label = 'Select Table',
##                                     command = self.evt_loadtable,
##                                     )
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
##                                     label = 'Select Orientation',
##                                     command = self.evt_loadorientation,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save TextObject',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setfont,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Table',
                                    label = 'Copy Table',
                                    command = gui_control.Command( self.evt_save_table_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Orientation',
                                    label = 'Copy Orientation',
                                    command = gui_control.Command( self.evt_save_orientation_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = gui_control.Command( self.evt_save_to_file, master ),
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close TextObject Editor',
                                    label = "Exit TextObject Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Table',
                             tag_bg=Tt_color,
                             tagindent=10,
                             hull_bg=Tt_color,
                             hull_highlightbackground=Tt_color,
                             hull_highlightcolor=Tt_color,
                            ring_bg=Tt_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables=self.canvas.listelements('texttable')
        tables.sort()

        labels=[]
        self.table=Pmw.OptionMenu(self.tproperties,
                                  items=tables,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadtable,
                                  initialitem=self.text.Tt_name,
                                  label_bg=Tt_color,
                                  hull_bg=Tt_color,
                                  menu_bg=Tt_color,
                                  menu_activebackground=Tt_color,
                                  menubutton_bg=Tt_color,
                                  menubutton_activebackground=Tt_color,
                                 )
        self.table.pack()
        labels.append(self.table)
        
        fonts=self.canvas.listelements("font")
        self.font=Pmw.OptionMenu(self.tproperties,
                                 items=fonts,
                                 labelpos='w',
                                 label_text='Font:',
                                 label_bg=Tt_color,
                                 hull_bg=Tt_color,
                                 menu_bg=Tt_color,
                                 menu_activebackground=Tt_color,
                                 menubutton_bg=Tt_color,
                                 menubutton_activebackground=Tt_color,
                                 command=self.setfont,
                                 )
        self.font.pack()
        labels.append(self.font)

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Spacing:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.spacing=Tkinter.Scale(f,
                                   bigincrement=10,
                                   from_=-50,
                                   to=50,
                                   orient='horizontal',
                                   tickinterval=25,
                                   length=200,
                                   bg=Tt_color,
                                   activebackground=Tt_color,
                                   highlightbackground=Tt_color,
                                   command=self.setfont,
                                  )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.expansion=Tkinter.Scale(f,
                                     bigincrement=10,
                                     from_=50,
                                     to=150,
                                     orient='horizontal',
                                     tickinterval=25,
                                     length=200,
                                     bg=Tt_color,
                                     activebackground=Tt_color,
                                     highlightbackground=Tt_color,
                                     command=self.setfont,
                                     )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=Tt_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=Tt_color,
                                 activebackground=Tt_color,
                                 highlightbackground=Tt_color,
                                 command=self.setfont,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels=[]
        self.oprop=Pmw.Group(parent,tag_text='Orientation',tagindent=10,tag_bg=To_color,ring_bg=To_color,hull_bg=To_color)
        self.oprop.pack(expand='yes',fill='both')
        self.oproperties=self.oprop.interior()
        self.oproperties.configure(bg=To_color)
        
        orientations=self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation=Pmw.OptionMenu(self.oproperties,
                                        items=orientations,
                                        labelpos='w',
                                        label_text='Name:',
                                        label_bg=To_color,
                                        hull_bg=To_color,
                                        menu_bg=To_color,
                                        menu_activebackground=To_color,
                                        menubutton_bg=To_color,
                                        menubutton_activebackground=To_color,
                                        command=self.loadorientation,
                                        initialitem=self.text.To_name,
                                 )
        self.orientation.pack()
        labels.append(self.orientation)
        
        self.height=Pmw.EntryField(self.oproperties,
                                   label_text='Size:',
                                   labelpos='w',
                                   label_justify='left',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   validate={'min':0,'validator':'real'},
                                   command=self.setfont,
                                   )
        self.height.pack()
        labels.append(self.height)
        
        f=Tkinter.Frame(self.oproperties,bg=To_color)
        l=Tkinter.Label(f,
                        text='Angle:',
                        bg=To_color,
                        )
        l.pack(side='left')
        labels.append(l)
        self.angle=Tkinter.Scale(f,
                                 bigincrement=30,
                                 from_=-180,
                                 to=180,
                                 orient='horizontal',
                                 tickinterval=90,
                                 length=200,
                                 bg=To_color,
                                 activebackground=To_color,
                                 highlightbackground=To_color,
                                 command=self.setfont,
                                 )
        self.angle.pack()
        f.pack()

        paths=["right","left","up","down"]
        self.path=Pmw.OptionMenu(self.oproperties,
                                 items=paths,
                                 labelpos='w',
                                 label_text='Path:',
                                 label_bg=To_color,
                                 hull_bg=To_color,
                                 menu_bg=To_color,
                                 menu_activebackground=To_color,
                                 menubutton_bg=To_color,
                                 menubutton_activebackground=To_color,
                                 command=self.setfont,
                                 )
        self.path.pack()
        labels.append(self.path)
        
        haligns=["left","center","right"]
        self.halign=Pmw.OptionMenu(self.oproperties,
                                   items=haligns,
                                   labelpos='w',
                                   label_text='Halign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.halign.pack()
        labels.append(self.halign)
        
        valigns=["top","cap","half","base","bottom"]
        self.valign=Pmw.OptionMenu(self.oproperties,
                                   items=valigns,
                                   labelpos='w',
                                   label_text='Valign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
示例#3
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        self.dialog_parent=dialog_parent
        self.master=master
        
#        print 'PASSED INSIDE:',gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas
            
        self.projection=self.canvas.getprojection(name)
        if self.projection is None:
            raise 'Erro invalid projection name'
        
        self.parent=Parent
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Proj_color = gui_support.gui_color.Proj_color

#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
##         if self.gui_parent is None:
##             self.gui_parent=Tkinter.Toplevel()
##             #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
##             self.gui_parent.withdraw()
#################################################################################################

        title='Projection Editor - '+self.projection.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Proj_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Projections', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open projection file',
                         label = 'Open Projection File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select projection',
##                                     label = 'Select',
##                                     command = self.evt_loadproj,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save projection',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setprojection,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy projection',
                                    label = 'Copy Projection',
                                    command = self.evt_save_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save as file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Projection Editor',
                                    label = "Exit Projection Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        projs=self.canvas.listelements('projection')
        projs.sort()

        self.projections=Pmw.OptionMenu(parent,
                                  items=projs,
                                  labelpos='w',
                                  label_text='Name: ',
                                  command=self.loadproj,
                                  initialitem=self.projection.name,
                                  label_bg=Proj_color,
                                  hull_bg=Proj_color,
                                  menu_bg=Proj_color,
                                  menu_activebackground=Proj_color,
                                  menubutton_bg=Proj_color,
                                  menubutton_activebackground=Proj_color,
                                 )
        self.projections.pack()
        
        self.fprop=Pmw.Group(parent,tag_text='Properties',
                             tagindent=10,
                             tag_bg=Proj_color,
                             ring_bg=Proj_color,
                             hull_bg=Proj_color)
        self.fprop.pack(expand='yes',fill='both')
        inter=self.fprop.interior()
        inter.configure(bg=Proj_color)
        self.fproperties=Tkinter.Frame(inter,bg=Proj_color)
        self.fbuttons=Tkinter.Frame(parent,bg=Proj_color)
        self.fbuttons.pack()

        self.projtypes=["polar (non gctp)",
                        "mollweide (non gctp)",
                        "robinson (non gctp)",
                        "linear",
                        "utm",
                        "state plane",
                        "albers equal area",
                        "lambert",
                        "mercator",
                        "polar stereographic",
                        "polyconic",
                        "equid conic",
                        "transverse mercator",
                        "stereographic",
                        "lambert azimuthal",
                        "azimuthal",
                        "gnomonic",
                        "orthographic",
                        "gen. vert. near per",
                        "sinusoidal",
                        "equirectangular",
                        "miller cylindrical",
                        "van der grinten",
                        "hotin oblique",
                        "robinson",
                        "space oblique",
                        "alaska conformal",
                        "interrupted goode",
                        "mollweide",
                        "interrupted mollweide",
                        "hammer",
                        "wagner iv",
                        "wagner vii",
                        "oblated equal area",
                        ]
        
        self.projtype = Pmw.OptionMenu (inter,
                                        labelpos='w',
                                        label_text='Projection Type',
                                        label_bg=Proj_color,
                                        hull_bg=Proj_color,
                                        menu_bg=Proj_color,
                                        menu_activebackground=Proj_color,
                                        menubutton_bg=Proj_color,
                                        menubutton_activebackground=Proj_color,
                                        items=  self.projtypes,
                                        command=self.settype,
                                        )
        self.projtype.pack()
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
示例#4
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            self.canvas = vcs.init()
        else:
            self.canvas = canvas

        self.line = self.canvas.getline(name)
        if self.line is None:
            if not name in vcs.listelements('line'):
                raise 'Error ' + t_name + ' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent = Parent
        self.parent_Name = self.parent.parent_Name
        ## Saves original values
        self.orig = []
        self.save_vals()

        L_color = gui_support.gui_color.L_color

        if self.gui_parent is None:
            self.gui_parent = Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title = 'Line Editor - table: ' + self.line.name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Line Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open line object file',
            label='Open LineObject File',
            command=self.evt_open_file,
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save Line',
            label='Save (i.e Apply changes)',
            command=self.setline,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Line',
            label='Copy Line',
            command=self.evt_save_line_as,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=self.evt_save_to_file,
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close Line Editor',
            label="Exit Line Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Line',
            tag_bg=L_color,
            tagindent=10,
            hull_bg=L_color,
            hull_highlightbackground=L_color,
            hull_highlightcolor=L_color,
            ring_bg=L_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines = vcs.listelements('line')
        lines.sort()

        labels = []
        self.Line = Pmw.OptionMenu(
            self.tproperties,
            items=lines,
            labelpos='w',
            label_text='Name:',
            command=self.loadline,
            initialitem=self.line.name,
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
        )
        self.Line.pack()
        labels.append(self.Line)
        items = ["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type = Pmw.OptionMenu(
            self.tproperties,
            items=items,
            labelpos='w',
            label_text='Type:',
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
            command=self.setline,
        )
        self.type.pack()
        labels.append(self.type)
        f = Tkinter.Frame(self.tproperties, bg=L_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=L_color,
        )
        l.pack(side='left')
        self.width = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=1,
            to=300,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )
        self.width.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=L_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=L_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
示例#5
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
            self.canvas=vcs.init()
        else:
            self.canvas=canvas

        self.line=self.canvas.getline(name)
        if self.line is None:
            if not name in self.canvas.listelements('line'):
                raise 'Error '+t_name+' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent=Parent
        self.parent_Name=self.parent.parent_Name
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        L_color = gui_support.gui_color.L_color
        
        if self.gui_parent is None:
            self.gui_parent=Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title='Line Editor - table: '+self.line.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Line Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open line object file',
                         label = 'Open LineObject File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem('File', 'command', 'Save Line',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setline,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Line',
                                    label = 'Copy Line',
                                    command = self.evt_save_line_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Line Editor',
                                    label = "Exit Line Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Line',
                             tag_bg=L_color,
                             tagindent=10,
                             hull_bg=L_color,
                             hull_highlightbackground=L_color,
                             hull_highlightcolor=L_color,
                            ring_bg=L_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines=self.canvas.listelements('line')
        lines.sort()

        labels=[]
        self.Line=Pmw.OptionMenu(self.tproperties,
                                  items=lines,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadline,
                                  initialitem=self.line.name,
                                  label_bg=L_color,
                                  hull_bg=L_color,
                                  menu_bg=L_color,
                                  menu_activebackground=L_color,
                                  menubutton_bg=L_color,
                                  menubutton_activebackground=L_color,
                                 )
        self.Line.pack()
        labels.append(self.Line)
        items=["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type=Pmw.OptionMenu(self.tproperties,
                                 items=items,
                                 labelpos='w',
                                 label_text='Type:',
                                 label_bg=L_color,
                                 hull_bg=L_color,
                                 menu_bg=L_color,
                                 menu_activebackground=L_color,
                                 menubutton_bg=L_color,
                                 menubutton_activebackground=L_color,
                                 command=self.setline,
                                 )
        self.type.pack()
        labels.append(self.type)
        f=Tkinter.Frame(self.tproperties,bg=L_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=L_color,
                        )
        l.pack(side='left')
        self.width=Tkinter.Scale(f,
                                 bigincrement=10,
                                 from_=1,
                                 to=300,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        self.width.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=L_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=L_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
示例#6
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 t_name='default',
                 o_name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            ##             import Canvas
            ##             self.canvas = Canvas.Canvas()
            self.canvas = vcs.init()
        else:
            self.canvas = canvas

        self.text = self.canvas.gettext(t_name, o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error ' + t_name + ' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error ' + o_name + ' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent = Parent
        try:
            self.parent_Name = self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig = []
        self.save_vals()

        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color

        #################################################################################################
        # At the moment, this will never happen. When we need to pop this editor up on its own, then we
        # will revist this case.
        #        if self.gui_parent is None:
        #            self.gui_parent=Tkinter.Toplevel()
        #            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
        #            self.gui_parent.withdraw()
        #################################################################################################

        title = 'Text Editor - table: ' + self.text.Tt_name + ', orientation: ' + self.text.To_name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Text Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open textobject file',
            label='Open TextObject File',
            command=gui_control.Command(self.evt_open_file, master),
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
        ##                                     label = 'Select Table',
        ##                                     command = self.evt_loadtable,
        ##                                     )
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
        ##                                     label = 'Select Orientation',
        ##                                     command = self.evt_loadorientation,
        ##                                     )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save TextObject',
            label='Save (i.e Apply changes)',
            command=self.setfont,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Table',
            label='Copy Table',
            command=gui_control.Command(self.evt_save_table_as, self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Orientation',
            label='Copy Orientation',
            command=gui_control.Command(self.evt_save_orientation_as,
                                        self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=gui_control.Command(self.evt_save_to_file, master),
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close TextObject Editor',
            label="Exit TextObject Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Table',
            tag_bg=Tt_color,
            tagindent=10,
            hull_bg=Tt_color,
            hull_highlightbackground=Tt_color,
            hull_highlightcolor=Tt_color,
            ring_bg=Tt_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables = self.canvas.listelements('texttable')
        tables.sort()

        labels = []
        self.table = Pmw.OptionMenu(
            self.tproperties,
            items=tables,
            labelpos='w',
            label_text='Name:',
            command=self.loadtable,
            initialitem=self.text.Tt_name,
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
        )
        self.table.pack()
        labels.append(self.table)

        fonts = self.canvas.listelements("font")
        self.font = Pmw.OptionMenu(
            self.tproperties,
            items=fonts,
            labelpos='w',
            label_text='Font:',
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
            command=self.setfont,
        )
        self.font.pack()
        labels.append(self.font)

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Spacing:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.spacing = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=-50,
            to=50,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.expansion = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=50,
            to=150,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=Tt_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels = []
        self.oprop = Pmw.Group(parent,
                               tag_text='Orientation',
                               tagindent=10,
                               tag_bg=To_color,
                               ring_bg=To_color,
                               hull_bg=To_color)
        self.oprop.pack(expand='yes', fill='both')
        self.oproperties = self.oprop.interior()
        self.oproperties.configure(bg=To_color)

        orientations = self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation = Pmw.OptionMenu(
            self.oproperties,
            items=orientations,
            labelpos='w',
            label_text='Name:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.loadorientation,
            initialitem=self.text.To_name,
        )
        self.orientation.pack()
        labels.append(self.orientation)

        self.height = Pmw.EntryField(
            self.oproperties,
            label_text='Size:',
            labelpos='w',
            label_justify='left',
            label_bg=To_color,
            hull_bg=To_color,
            validate={
                'min': 0,
                'validator': 'real'
            },
            command=self.setfont,
        )
        self.height.pack()
        labels.append(self.height)

        f = Tkinter.Frame(self.oproperties, bg=To_color)
        l = Tkinter.Label(
            f,
            text='Angle:',
            bg=To_color,
        )
        l.pack(side='left')
        labels.append(l)
        self.angle = Tkinter.Scale(
            f,
            bigincrement=30,
            from_=-180,
            to=180,
            orient='horizontal',
            tickinterval=90,
            length=200,
            bg=To_color,
            activebackground=To_color,
            highlightbackground=To_color,
            command=self.setfont,
        )
        self.angle.pack()
        f.pack()

        paths = ["right", "left", "up", "down"]
        self.path = Pmw.OptionMenu(
            self.oproperties,
            items=paths,
            labelpos='w',
            label_text='Path:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.path.pack()
        labels.append(self.path)

        haligns = ["left", "center", "right"]
        self.halign = Pmw.OptionMenu(
            self.oproperties,
            items=haligns,
            labelpos='w',
            label_text='Halign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.halign.pack()
        labels.append(self.halign)

        valigns = ["top", "cap", "half", "base", "bottom"]
        self.valign = Pmw.OptionMenu(
            self.oproperties,
            items=valigns,
            labelpos='w',
            label_text='Valign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return