import wx
import webbrowser
import logging
from GUI.MainPanel import MainPanel
from os import path

path_to_module = path.dirname(__file__)

class MainFrame(wx.Frame):

    def __init__(self, parent=None):

        self.parent = parent
        self.display_size = wx.GetDisplaySize()
        self.num_of_monitors = wx.Display_GetCount()

        WIDTH_PCT = 0.85
        HEIGHT_PCT = 0.75
        self.WINDOW_SIZE_WIDTH = (
            self.display_size.x/self.num_of_monitors) * WIDTH_PCT
        self.WINDOW_SIZE_HEIGHT = (self.display_size.y) * HEIGHT_PCT

        self.WINDOW_MAX_WIDTH = 900
        self.WINDOW_MAX_HEIGHT = 800
        self.MIN_WIDTH_SIZE = 600
        self.MIN_HEIGHT_SIZE = 400
        if self.WINDOW_SIZE_WIDTH > self.WINDOW_MAX_WIDTH:
            self.WINDOW_SIZE_WIDTH = self.WINDOW_MAX_WIDTH
        if self.WINDOW_SIZE_HEIGHT > self.WINDOW_MAX_HEIGHT:
            self.WINDOW_SIZE_HEIGHT = self.WINDOW_MAX_HEIGHT

        self.WINDOW_SIZE = (self.WINDOW_SIZE_WIDTH, self.WINDOW_SIZE_HEIGHT)

        wx.Frame.__init__(self, parent=self.parent, id=wx.ID_ANY,
                          title="IRIDA Uploader",
                          size=self.WINDOW_SIZE,
                          style=wx.DEFAULT_FRAME_STYLE)

        self.mp = MainPanel(self)
        self.settings_frame = self.mp.settings_frame

        img_dir_path = path.join(path_to_module, "images")
        self.icon = wx.Icon(path.join(img_dir_path, "iu.ico"),
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.add_options_menu()
        self.add_file_menu()
        self.add_settings_option()
        self.add_documentation_option()

        self.SetSizeHints(self.MIN_WIDTH_SIZE, self.MIN_HEIGHT_SIZE,
                          self.WINDOW_MAX_WIDTH, self.WINDOW_MAX_HEIGHT)
        self.Bind(wx.EVT_CLOSE, self.mp.close_handler)
        self.Center()

    def add_options_menu(self):

        """
        Adds Options menu on top of program
        Shortcut / accelerator: Alt + T

        no return value
        """

        self.menubar = wx.MenuBar()
        self.options_menu = wx.Menu()
        self.file_menu = wx.Menu()
        self.menubar.Append(self.file_menu, "&File")
        self.menubar.Append(self.options_menu, "Op&tions")
        self.SetMenuBar(self.menubar)

    def add_file_menu(self):
        exit_menu = self.file_menu.Append(wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, lambda evt: self.Destroy(), exit_menu)

    def add_settings_option(self):

        """
        Add Settings on options menu
        Clicking Settings will call self.open_settings()
        Shortcut / accelerator: (Alt + T) + S or (CTRL + I)

        no return value
        """
        open_menu = self.options_menu.Append(wx.ID_PROPERTIES, "Settings")
        self.Bind(wx.EVT_MENU, self.open_settings, open_menu)

    def open_settings(self, evt):

        """
        Open the settings menu(SettingsFrame)

        no return value
        """

        self.settings_frame.Center()
        self.settings_frame.Show()

    def add_documentation_option(self):

        """
        Adds Documentation on options menu
        Clicking Documentation will call self.open_docs()
        Accelerator: ALT + T + D

        no return value
        """

        docs_menu = self.options_menu.Append(wx.ID_HELP, "&Documentation")
        self.Bind(wx.EVT_MENU, self.open_docs, docs_menu)

    def open_docs(self, evt):

        """
        Open documentation with user's default browser

        no return value
        """
        docs_path = path.join(path_to_module, "..", "..", "html",
                              "index.html")
        logging.info(path_to_module)
        wx.CallAfter(webbrowser.open, docs_path)

@@ -1548,127 +1548,14 @@
 add_
-options_menu()%0A        self.add_file_menu()%0A        self.add_settings_option()%0A        self.add_documentation_option()%0A
+menu()
 %0A   
@@ -1783,24 +1783,16 @@
 def add_
-options_
 menu(sel
@@ -1970,46 +1970,8 @@
 r()%0A
-        self.options_menu = wx.Menu()%0A
     
@@ -2054,24 +2054,25 @@
 &File%22)%0A
+%0A
         
 self.men
@@ -2063,36 +2063,50 @@
         
-self.
+open_menu = self.file_
 menu
-bar
 .Append(
 self.opt
@@ -2101,106 +2101,100 @@
 end(
-self.options_menu, %22Op&tions%22)%0A        self.SetMenuBar(self.menubar)%0A%0A    def add_file_menu(self):
+wx.ID_PROPERTIES, %22Settings%22)%0A        self.Bind(wx.EVT_MENU, self.open_settings, open_menu)%0A
 %0A   
@@ -2198,20 +2198,20 @@
         
-exit
+docs
 _menu = 
@@ -2242,12 +2242,30 @@
 .ID_
-EXIT
+HELP, %22&Documentation%22
 )%0A  
@@ -2297,132 +2297,35 @@
 NU, 
-lambda evt: self.Destroy(), exit_menu)%0A%0A    def add_settings_option(self):%0A%0A        %22%22%22%0A        Add Settings on options 
+self.open_docs, docs_
 menu
+)%0A
 %0A   
@@ -2333,166 +2333,54 @@
     
-Clicking Settings will call self.open_settings()%0A        Shortcut / accelerator: (Alt + T) + S or (CTRL + I)%0A%0A        no return value%0A        %22%22%22%0A        open
+self.file_menu.AppendSeparator()%0A%0A        exit
 _men
@@ -2380,39 +2380,36 @@
 xit_menu = self.
-options
+file
 _menu.Append(wx.
@@ -2411,38 +2411,20 @@
 d(wx.ID_
-PROPERTIES, %22Settings%22
+EXIT
 )%0A      
@@ -2452,37 +2452,84 @@
 NU, 
-self.open_settings, open_
+lambda evt: self.Destroy(), exit_menu)%0A%0A        self.SetMenuBar(self.
 menu
+bar
 )%0A%0A 
@@ -2735,367 +2735,8 @@
 ()%0A%0A
-    def add_documentation_option(self):%0A%0A        %22%22%22%0A        Adds Documentation on options menu%0A        Clicking Documentation will call self.open_docs()%0A        Accelerator: ALT + T + D%0A%0A        no return value%0A        %22%22%22%0A%0A        docs_menu = self.options_menu.Append(wx.ID_HELP, %22&Documentation%22)%0A        self.Bind(wx.EVT_MENU, self.open_docs, docs_menu)%0A%0A
     

Put everything into a single menu.