← Back to team overview

cdd-dev team mailing list archive

Re: [Branch ~cdd-dev/cdd/trunk] Rev 204: Inserted metadata panel inside cdd right panel.

 

Awesome!  Looks great.


On Tue, Jul 31, 2012 at 4:08 AM,  <noreply@xxxxxxxxxxxxx> wrote:
> ------------------------------------------------------------
> revno: 204
> committer: Eduardo C. P. Ribeiro <eduardo.cesar@xxxxxxx>
> branch nick: cdd
> timestamp: Tue 2012-07-31 04:07:27 -0300
> message:
>   Inserted metadata panel inside cdd right panel.
> modified:
>   src/cdd.py
>   src/cdg_cdd.wxg
>   src/cdg_main.py
>   src/mlhim2.py
>
>
> --
> lp:cdd
> https://code.launchpad.net/~cdd-dev/cdd/trunk
>
> Your team CDD Developers is subscribed to branch lp:cdd.
> To unsubscribe from this branch go to https://code.launchpad.net/~cdd-dev/cdd/trunk/+edit-subscription
>
> === modified file 'src/cdd.py'
> --- src/cdd.py  2012-07-30 00:54:47 +0000
> +++ src/cdd.py  2012-07-31 07:07:27 +0000
> @@ -121,7 +121,7 @@
>              icon = wx.IconFromBitmap(bitmap)
>              self.SetIcon(icon)
>
> -        self.SetSize((800, 600))
> +        self.SetSize((900, 600))
>          self.SetBackgroundColour(wx.Colour(228, 228, 228))
>          font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
>          font.SetPointSize(12)
> @@ -136,9 +136,9 @@
>              self.statusbar.SetStatusText(statusbar_fields[i], i)
>
>          # begin MainFrame set properties
> -        self.hbox1 = wx.BoxSizer(wx.HORIZONTAL)
> -        self.vbox1 = wx.BoxSizer(wx.VERTICAL)
> -        self.vbox2 = wx.BoxSizer(wx.VERTICAL)
> +        self.hbox_principal = wx.BoxSizer(wx.HORIZONTAL)
> +        self.vbox_panel1 = wx.BoxSizer(wx.VERTICAL)
> +        self.vbox_panel2 = wx.BoxSizer(wx.VERTICAL)
>          self.panel1 = wx.Panel(self, -1)
>          self.panel2 = wx.Panel(self, -1)
>
> @@ -154,12 +154,14 @@
>
>
>          # do  layout
> -        self.vbox1.Add(self.tree, 1, wx.EXPAND)
> -        self.hbox1.Add(self.panel1, 1, wx.EXPAND)
> -        self.hbox1.Add(self.panel2, 1, wx.EXPAND)
> -        self.panel1.SetSizer(self.vbox1)
> -        self.panel2.SetSizer(self.vbox2)
> -        self.SetSizer(self.hbox1)
> +        self.SetSizer(self.hbox_principal)
> +        self.vbox_panel1.Add(self.tree, 1, wx.EXPAND)
> +        self.hbox_principal.Add(self.panel1, 1, wx.EXPAND)
> +        self.hbox_principal.Add(self.panel2, 3, wx.EXPAND)
> +        self.panel1.SetSizer(self.vbox_panel1)
> +
> +        self.panel2.SetSizer(self.vbox_panel2)
> +
>
>          self.tree.SetFocus()
>          self.Centre()
> @@ -170,9 +172,19 @@
>
>          self.config_dialog = cdg_main.ConfigDialog(self)
>          self.config_dialog.test_workspace_dir(self)
> -        self.metadata = mlhim2.Metadata(self)
> -        self.metadata.read_config()
> -        info.get_meta_info(self.metadata)
> +
> +        # Hack to make the metadata panel before it is called
> +        # We need to make it before to be able to get the info from it
> +        # at the program start
> +        self.dummy_panel = wx.Panel(self.panel2, -1)
> +        self.dummy_panel.Hide()
> +        self.metadata = mlhim2.Metadata(self.dummy_panel)
> +        self.metadata.info = info
> +        self.metadata.set_meta_info()
> +
> +
> +        # self.metadata.read_config()
> +        # info.get_meta_info(self.metadata)
>
>
>
> @@ -189,12 +201,19 @@
>              #self.display.SetLabel(_("You are at the root, nothing to do here."))
>
>          elif selText == "Metadata":
> -            result = self.metadata.ShowModal()
> -            if result == wx.ID_OK:
> -                self.metadata.save_config()
> -
> -                # Extract the necessary information from the metadata dialog
> -                info.get_meta_info(self.metadata)
> +
> +
> +            self.metadata.Reparent(self.panel2)
> +            # _data = mlhim2.Metadata(self.panel2)
> +
> +            # _data.info = info
> +
> +            # _data.SetSizer(sizer)
> +            # if result == wx.ID_OK:
> +            #     self.metadata.save_config()
> +
> +            #     # Extract the necessary information from the metadata dialog
> +            #     info.get_meta_info(self.metadata)
>
>
>          elif selText == "definition":
>
> === modified file 'src/cdg_cdd.wxg'
> --- src/cdg_cdd.wxg     2012-07-27 23:27:36 +0000
> +++ src/cdg_cdd.wxg     2012-07-31 07:07:27 +0000
> @@ -1,11 +1,116 @@
>  <?xml version="1.0"?>
> -<!-- generated by wxGlade 0.6.4 on Fri Jul 27 19:23:47 2012 -->
> +<!-- generated by wxGlade 0.6.4 on Tue Jul 31 03:25:15 2012 -->
>
>  <application path="cdg_main.py" name="" class="" option="0" language="python" top_window="frame_principal" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
> -    <object class="MetadataDialog" name="dialog_principal" base="EditDialog">
> +    <object class="ConfigDialog" name="dialog_config" base="EditDialog">
>          <style>wxDEFAULT_DIALOG_STYLE</style>
> -        <title>Metadata</title>
> -        <size>800, 470</size>
> +        <title>Configuration</title>
> +        <size>596, 158</size>
> +        <object class="wxBoxSizer" name="sizer_main" base="EditBoxSizer">
> +            <orient>wxVERTICAL</orient>
> +            <object class="sizeritem">
> +                <flag>wxEXPAND</flag>
> +                <border>0</border>
> +                <option>1</option>
> +                <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
> +                    <orient>wxHORIZONTAL</orient>
> +                    <object class="sizeritem">
> +                        <flag>wxEXPAND</flag>
> +                        <border>7</border>
> +                        <option>1</option>
> +                        <object class="wxStaticBoxSizer" name="sizer_9" base="EditStaticBoxSizer">
> +                            <orient>wxHORIZONTAL</orient>
> +                            <label>Workspace path:</label>
> +                            <object class="sizeritem">
> +                                <border>0</border>
> +                                <option>1</option>
> +                                <object class="wxTextCtrl" name="text_ctrl_workspace" base="EditTextCtrl">
> +                                </object>
> +                            </object>
> +                        </object>
> +                    </object>
> +                    <object class="sizerslot" />
> +                </object>
> +            </object>
> +            <object class="sizeritem">
> +                <flag>wxEXPAND</flag>
> +                <border>0</border>
> +                <option>1</option>
> +                <object class="wxBoxSizer" name="sizer_11" base="EditBoxSizer">
> +                    <orient>wxHORIZONTAL</orient>
> +                    <object class="sizeritem">
> +                        <flag>wxEXPAND</flag>
> +                        <border>0</border>
> +                        <option>0</option>
> +                        <object class="wxStaticBoxSizer" name="sizer_12" base="EditStaticBoxSizer">
> +                            <orient>wxHORIZONTAL</orient>
> +                            <label>Autosave timer: </label>
> +                            <object class="sizeritem">
> +                                <border>0</border>
> +                                <option>0</option>
> +                                <object class="wxTextCtrl" name="text_ctrl_autosave" base="EditTextCtrl">
> +                                    <size>110, 27</size>
> +                                </object>
> +                            </object>
> +                        </object>
> +                    </object>
> +                    <object class="sizeritem">
> +                        <flag>wxEXPAND</flag>
> +                        <border>0</border>
> +                        <option>1</option>
> +                        <object class="spacer" name="spacer" base="EditSpacer">
> +                            <height>20</height>
> +                            <width>20</width>
> +                        </object>
> +                    </object>
> +                </object>
> +            </object>
> +            <object class="sizeritem">
> +                <flag>wxEXPAND</flag>
> +                <border>0</border>
> +                <option>1</option>
> +                <object class="wxBoxSizer" name="sizer_10" base="EditBoxSizer">
> +                    <orient>wxHORIZONTAL</orient>
> +                    <object class="sizeritem">
> +                        <border>0</border>
> +                        <option>1</option>
> +                        <object class="spacer" name="spacer" base="EditSpacer">
> +                            <height>20</height>
> +                            <width>20</width>
> +                        </object>
> +                    </object>
> +                    <object class="sizeritem">
> +                        <flag>wxALIGN_CENTER_VERTICAL</flag>
> +                        <border>0</border>
> +                        <option>0</option>
> +                        <object class="wxButton" name="button_2" base="EditButton">
> +                            <stockitem>CANCEL</stockitem>
> +                            <label>&amp;Cancel</label>
> +                        </object>
> +                    </object>
> +                    <object class="sizeritem">
> +                        <border>0</border>
> +                        <option>0</option>
> +                        <object class="spacer" name="spacer" base="EditSpacer">
> +                            <height>20</height>
> +                            <width>20</width>
> +                        </object>
> +                    </object>
> +                    <object class="sizeritem">
> +                        <flag>wxALIGN_CENTER_VERTICAL</flag>
> +                        <border>0</border>
> +                        <option>0</option>
> +                        <object class="wxButton" name="button_1" base="EditButton">
> +                            <stockitem>OK</stockitem>
> +                            <label>&amp;OK</label>
> +                        </object>
> +                    </object>
> +                </object>
> +            </object>
> +        </object>
> +    </object>
> +    <object class="MetadataPanel" name="panel_metadata" base="EditTopLevelPanel">
> +        <style>wxTAB_TRAVERSAL</style>
>          <object class="wxBoxSizer" name="sizer_vertical" base="EditBoxSizer">
>              <orient>wxHORIZONTAL</orient>
>              <object class="sizeritem">
> @@ -375,29 +480,15 @@
>                                  </object>
>                              </object>
>                              <object class="sizeritem">
> -                                <flag>wxALIGN_RIGHT|wxALIGN_BOTTOM|wxALIGN_CENTER_VERTICAL</flag>
> -                                <border>1</border>
> -                                <option>0</option>
> -                                <object class="wxButton" name="button_cancel" base="EditButton">
> -                                    <stockitem>CANCEL</stockitem>
> -                                    <label>&amp;Cancel</label>
> -                                </object>
> -                            </object>
> -                            <object class="sizeritem">
> -                                <border>0</border>
> -                                <option>0</option>
> -                                <object class="spacer" name="spacer" base="EditSpacer">
> -                                    <height>20</height>
> -                                    <width>20</width>
> -                                </object>
> -                            </object>
> -                            <object class="sizeritem">
>                                  <flag>wxALIGN_BOTTOM</flag>
>                                  <border>0</border>
>                                  <option>0</option>
>                                  <object class="wxButton" name="button_ok" base="EditButton">
>                                      <stockitem>OK</stockitem>
>                                      <label>&amp;OK</label>
> +                                    <events>
> +                                        <handler event="EVT_BUTTON">save_config</handler>
> +                                    </events>
>                                  </object>
>                              </object>
>                          </object>
> @@ -422,111 +513,4 @@
>              </object>
>          </object>
>      </object>
> -    <object class="ConfigDialog" name="dialog_config" base="EditDialog">
> -        <style>wxDEFAULT_DIALOG_STYLE</style>
> -        <title>Configuration</title>
> -        <size>596, 158</size>
> -        <object class="wxBoxSizer" name="sizer_main" base="EditBoxSizer">
> -            <orient>wxVERTICAL</orient>
> -            <object class="sizeritem">
> -                <flag>wxEXPAND</flag>
> -                <border>0</border>
> -                <option>1</option>
> -                <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
> -                    <orient>wxHORIZONTAL</orient>
> -                    <object class="sizeritem">
> -                        <flag>wxEXPAND</flag>
> -                        <border>7</border>
> -                        <option>1</option>
> -                        <object class="wxStaticBoxSizer" name="sizer_9" base="EditStaticBoxSizer">
> -                            <orient>wxHORIZONTAL</orient>
> -                            <label>Workspace path:</label>
> -                            <object class="sizeritem">
> -                                <border>0</border>
> -                                <option>1</option>
> -                                <object class="wxTextCtrl" name="text_ctrl_workspace" base="EditTextCtrl">
> -                                </object>
> -                            </object>
> -                        </object>
> -                    </object>
> -                    <object class="sizerslot" />
> -                </object>
> -            </object>
> -            <object class="sizeritem">
> -                <flag>wxEXPAND</flag>
> -                <border>0</border>
> -                <option>1</option>
> -                <object class="wxBoxSizer" name="sizer_11" base="EditBoxSizer">
> -                    <orient>wxHORIZONTAL</orient>
> -                    <object class="sizeritem">
> -                        <flag>wxEXPAND</flag>
> -                        <border>0</border>
> -                        <option>0</option>
> -                        <object class="wxStaticBoxSizer" name="sizer_12" base="EditStaticBoxSizer">
> -                            <orient>wxHORIZONTAL</orient>
> -                            <label>Autosave timer: </label>
> -                            <object class="sizeritem">
> -                                <border>0</border>
> -                                <option>0</option>
> -                                <object class="wxTextCtrl" name="text_ctrl_autosave" base="EditTextCtrl">
> -                                    <size>110, 27</size>
> -                                </object>
> -                            </object>
> -                        </object>
> -                    </object>
> -                    <object class="sizeritem">
> -                        <flag>wxEXPAND</flag>
> -                        <border>0</border>
> -                        <option>1</option>
> -                        <object class="spacer" name="spacer" base="EditSpacer">
> -                            <height>20</height>
> -                            <width>20</width>
> -                        </object>
> -                    </object>
> -                </object>
> -            </object>
> -            <object class="sizeritem">
> -                <flag>wxEXPAND</flag>
> -                <border>0</border>
> -                <option>1</option>
> -                <object class="wxBoxSizer" name="sizer_10" base="EditBoxSizer">
> -                    <orient>wxHORIZONTAL</orient>
> -                    <object class="sizeritem">
> -                        <border>0</border>
> -                        <option>1</option>
> -                        <object class="spacer" name="spacer" base="EditSpacer">
> -                            <height>20</height>
> -                            <width>20</width>
> -                        </object>
> -                    </object>
> -                    <object class="sizeritem">
> -                        <flag>wxALIGN_CENTER_VERTICAL</flag>
> -                        <border>0</border>
> -                        <option>0</option>
> -                        <object class="wxButton" name="button_2" base="EditButton">
> -                            <stockitem>CANCEL</stockitem>
> -                            <label>&amp;Cancel</label>
> -                        </object>
> -                    </object>
> -                    <object class="sizeritem">
> -                        <border>0</border>
> -                        <option>0</option>
> -                        <object class="spacer" name="spacer" base="EditSpacer">
> -                            <height>20</height>
> -                            <width>20</width>
> -                        </object>
> -                    </object>
> -                    <object class="sizeritem">
> -                        <flag>wxALIGN_CENTER_VERTICAL</flag>
> -                        <border>0</border>
> -                        <option>0</option>
> -                        <object class="wxButton" name="button_1" base="EditButton">
> -                            <stockitem>OK</stockitem>
> -                            <label>&amp;OK</label>
> -                        </object>
> -                    </object>
> -                </object>
> -            </object>
> -        </object>
> -    </object>
>  </application>
>
> === modified file 'src/cdg_main.py'
> --- src/cdg_main.py     2012-07-30 00:54:47 +0000
> +++ src/cdg_main.py     2012-07-31 07:07:27 +0000
> @@ -22,11 +22,12 @@
>  # end wxGlade
>
>
> -class MetadataDialog(wx.Dialog):
> +
> +class MetadataPanel(wx.Panel):
>      def __init__(self, *args, **kwds):
> -        # begin wxGlade: MetadataDialog.__init__
> -        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
> -        wx.Dialog.__init__(self, *args, **kwds)
> +        # begin wxGlade: MetadataPanel.__init__
> +        kwds["style"] = wx.TAB_TRAVERSAL
> +        wx.Panel.__init__(self, *args, **kwds)
>          self.label_title = wx.StaticText(self, -1, "* Title:  ", style=wx.ALIGN_CENTRE)
>          self.text_ctrl_title = wx.TextCtrl(self, -1, "")
>          self.label_date = wx.StaticText(self, -1, "Date :")
> @@ -53,18 +54,19 @@
>          self.text_ctrl_coverage = wx.TextCtrl(self, -1, "")
>          self.label_contributors = wx.StaticText(self, -1, "Contributors:  ")
>          self.text_ctrl_contributors = wx.TextCtrl(self, -1, "")
> -        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
>          self.button_ok = wx.Button(self, wx.ID_OK, "")
>
>          self.__set_properties()
>          self.__do_layout()
> +
> +        self.Bind(wx.EVT_BUTTON, self.save_config, self.button_ok)
>          # end wxGlade
> +
>          self.init_things()
>
>      def __set_properties(self):
> -        # begin wxGlade: MetadataDialog.__set_properties
> -        self.SetTitle("Metadata")
> -        self.SetSize((800, 470))
> +        # begin wxGlade: MetadataPanel.__set_properties
> +        self.SetSize((677, 577))
>          self.label_date.SetToolTipString("Defalts to current day.")
>          self.datepicker_ctrl_date.SetMinSize((111, 28))
>          self.choice_lang.SetItems(get_lang_list())
> @@ -78,7 +80,7 @@
>          # end wxGlade
>
>      def __do_layout(self):
> -        # begin wxGlade: MetadataDialog.__do_layout
> +        # begin wxGlade: MetadataPanel.__do_layout
>          sizer_vertical = wx.BoxSizer(wx.HORIZONTAL)
>          sizer_3 = wx.BoxSizer(wx.VERTICAL)
>          sizer_2_copy = wx.BoxSizer(wx.HORIZONTAL)
> @@ -130,21 +132,44 @@
>          sizer_1.Add(self.text_ctrl_contributors, 1, wx.ALIGN_CENTER_VERTICAL, 1)
>          sizer_3.Add(sizer_1, 1, wx.EXPAND, 0)
>          sizer_2_copy.Add((20, 20), 1, wx.EXPAND, 1)
> -        sizer_2_copy.Add(self.button_cancel, 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_VERTICAL, 1)
> -        sizer_2_copy.Add((20, 20), 0, 0, 0)
>          sizer_2_copy.Add(self.button_ok, 0, wx.ALIGN_BOTTOM, 0)
>          sizer_3.Add(sizer_2_copy, 1, wx.EXPAND, 0)
>          sizer_3.Add((20, 20), 0, 0, 0)
>          sizer_vertical.Add(sizer_3, 1, wx.EXPAND, 0)
>          sizer_vertical.Add((20, 20), 0, 0, 0)
>          self.SetSizer(sizer_vertical)
> -        self.Layout()
>          # end wxGlade
> -
> +
>      def init_things(self):
> +        self.info = None
>          self.init_config()
>          self.read_config()
>
> +
> +    def set_meta_info(self):
> +        if self.info:
> +            title = self.text_ctrl_title.GetValue().encode('utf8')
> +            description = self.text_ctrl_description.GetValue().encode('utf8')
> +            creator = self.text_ctrl_creator.GetValue().encode('utf8')
> +            creator_email = self.text_ctrl_creator_email.GetValue().encode('utf8')
> +            contributor = self.text_ctrl_contributors.GetValue().encode('utf8')
> +
> +            publisher = self.text_ctrl_publisher.GetValue().encode('utf8')
> +            subject = self.text_ctrl_subject.GetValue().encode('utf8')
> +            source = self.text_ctrl_source.GetValue().encode('utf8')
> +            rights = self.text_ctrl_rights.GetValue().encode('utf8')
> +            relation = self.text_ctrl_relation.GetValue().encode('utf8')
> +            coverage = self.text_ctrl_coverage.GetValue().encode('utf8')
> +
> +            language = self.choice_lang.GetStringSelection()
> +
> +            tempo = self.datepicker_ctrl_date.GetValue()
> +            date = '{Y}-{M:02}-{D:02}'.format(Y=tempo.GetYear(), M=tempo.GetMonth()+1, D=tempo.GetDay())
> +
> +            self.info.get_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
> +
> +
> +
>      def init_config(self):
>          if sys.platform.startswith('linux'):
>              home = os.environ['HOME']
> @@ -183,7 +208,7 @@
>          self.config.read(self.configname)
>          self.set_panel_configs()
>
> -    def save_config(self):
> +    def save_config(self, event=None):   # wxGlade: MetadataPanel.<event_handler>
>          self.get_panel_configs()
>          try:
>              with open(self.configname, 'wb') as configfile:
> @@ -192,6 +217,7 @@
>          except IOError:
>              popup_message(None, 'Config could not be saved.', 'Error saving config', wx.ICON_EXCLAMATION)
>
> +        self.set_meta_info()
>
>      def get_panel_configs(self):
>          self.config.set('DEFAULT', 'title', self.text_ctrl_title.GetValue().encode('utf8'))
> @@ -225,8 +251,7 @@
>
>          self.choice_lang.SetSelection(int(self.config.get('DEFAULT', 'language')))
>
> -
> -# end of class MetadataDialog
> +# end of class MetadataPanel
>
>  class ConfigDialog(wx.Dialog):
>      def __init__(self, *args, **kwds):
>
> === modified file 'src/mlhim2.py'
> --- src/mlhim2.py       2012-07-27 23:27:36 +0000
> +++ src/mlhim2.py       2012-07-31 07:07:27 +0000
> @@ -15,7 +15,7 @@
>  _ = gettext.gettext
>
>  # form for entering metadata.
> -class Metadata(cdg_main.MetadataDialog):
> +class Metadata(cdg_main.MetadataPanel):
>      pass
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~cdd-dev
> Post to     : cdd-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~cdd-dev
> More help   : https://help.launchpad.net/ListHelp
>



-- 
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
Academic.Edu Profile: http://uff.academia.edu/TimothyCook


References