2019年4月4日 星期四

[ Python 文章收集 ] wxPython - Menus and toolbars

Source From Here 
Preface 
A common part in a GUI application is a menubar. A menubar consists of objects called menus. Top-level menus have their labels on the menubar. The menus have menu items. Menu items are commands that perform a specific action inside the application. Menus can also have submenus, which have their own menu items. The following three classes are used to create menubars in wxPython: a wx.MenuBar, a wx.Menu and a wx.MenuItem

Simple menu 
In our first example, we will create a menubar with one file menu. The menu will have only one menu item. By selecting the item the application quits. 
simple_menu.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. This example shows a simple menu.  
  8.   
  9. author: Jan Bodnar  
  10. website: www.zetcode.com  
  11. last modified: April 2018  
  12. """  
  13.   
  14. import wx  
  15.   
  16.   
  17. class Example(wx.Frame):  
  18.   
  19.     def __init__(self, *args, **kwargs):  
  20.         super(Example, self).__init__(*args, **kwargs)  
  21.   
  22.         self.InitUI()  
  23.   
  24.     def InitUI(self):  
  25.   
  26.         menubar = wx.MenuBar()  
  27.         fileMenu = wx.Menu()  
  28.         fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit''Quit application')  
  29.         menubar.Append(fileMenu, '&File')  
  30.         self.SetMenuBar(menubar)  
  31.   
  32.         self.Bind(wx.EVT_MENU, self.OnQuit, fileItem)  
  33.   
  34.         self.SetSize((300200))  
  35.         self.SetTitle('Simple menu')  
  36.         self.Centre()  
  37.   
  38.     def OnQuit(self, e):  
  39.         self.Close()  
  40.   
  41.   
  42. def main():  
  43.   
  44.     app = wx.App()  
  45.     ex = Example(None)  
  46.     ex.Show()  
  47.     app.MainLoop()  
  48.   
  49.   
  50. if __name__ == '__main__':  
  51.     main()  
Below is a small example with minimal menubar functionality: 
  1. menubar = wx.MenuBar()  
First we create a menubar object: 
  1. fileMenu = wx.Menu()  
Next we create a menu object: 
  1. fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit''Quit application')  
We append a menu item into the menu object. The first parameter is the id of the menu item. The standard id will automatically add an icon and a shortcut, Ctrl+Q in our case. The second parameter is the name of the menu item. The last parameter defines the short help string that is displayed on the statusbar, when the menu item is selected. Here we did not create a wx.MenuItem explicitly. It was created by the Append() method behind the scenes. The method returns the created menu item. This reference will be used later to bind an event: 
  1. self.Bind(wx.EVT_MENU, self.OnQuit, fileItem)  
We bind the wx.EVT_MENU of the menu item to the custom OnQuit() method. This method will close the application. After that, we append a menu into the menubar: 
  1. menubar.Append(fileMenu, '&File')  
  2. self.SetMenuBar(menubar)  
The & character creates an accelerator key. The character that follows the & is underlined. This way the menu is accessible via the Alt+F shortcut. In the end, we call the SetMenuBar() method. This method belongs to the wx.Frame widget. It sets up the menubar: 


Icons and shortcuts 
The next example is essentially the same as the previous one. This time, we manually create a wx.MenuItem 
- icons_shortcuts.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. In this example, we manually create  
  8. a menu item.  
  9.   
  10. author: Jan Bodnar  
  11. website: www.zetcode.com  
  12. last modified: April 2018  
  13. """  
  14.   
  15. import wx  
  16.   
  17. APP_EXIT = 1  
  18.   
  19.   
  20. class Example(wx.Frame):  
  21.   
  22.     def __init__(self, *args, **kwargs):  
  23.         super(Example, self).__init__(*args, **kwargs)  
  24.   
  25.         self.InitUI()  
  26.   
  27.     def InitUI(self):  
  28.   
  29.         menubar = wx.MenuBar()  
  30.         fileMenu = wx.Menu()  
  31.         qmi = wx.MenuItem(fileMenu, APP_EXIT, '&Quit\tCtrl+Q')  
  32.         qmi.SetBitmap(wx.Bitmap('exit.png'))  
  33.         fileMenu.Append(qmi)  
  34.   
  35.         self.Bind(wx.EVT_MENU, self.OnQuit, id=APP_EXIT)  
  36.   
  37.         menubar.Append(fileMenu, '&File')  
  38.         self.SetMenuBar(menubar)  
  39.   
  40.         self.SetSize((350250))  
  41.         self.SetTitle('Icons and shortcuts')  
  42.         self.Centre()  
  43.           
  44.     def OnQuit(self, e):  
  45.         self.Close()  
  46.   
  47.   
  48. def main():  
  49.   
  50.     app = wx.App()  
  51.     ex = Example(None)  
  52.     ex.Show()  
  53.     app.MainLoop()  
  54.   
  55.   
  56. if __name__ == '__main__':  
  57.     main()  
In this example, we create a quit menu item. We choose a custom icon and shortcut for the menu item. 
  1. qmi = wx.MenuItem(fileMenu, APP_EXIT, '&Quit\tCtrl+Q')  
  2. qmi.SetBitmap(wx.Bitmap('exit.png'))  
  3. fileMenu.Append(qmi)  
We create a wx.MenuItem object. The & character specifies an accelerator key. The character following the ampersand is underlined. The actual shortcut is defined by the combination of characters. We have specified Ctrl+Q characters. So if we press Ctrl+Q, we close the application. We put a tab character between the & character and the shortcut. This way, we manage to put some space between them. To provide an icon for a menu item, we call a SetBitmap() method. A manually created menu item is appended to the menu by calling the AppendItem() method. 
  1. self.Bind(wx.EVT_MENU, self.OnQuit, id=APP_EXIT)  
When we select the created menu item, the OnQuit() method is called. 


Submenus and separators 
Each menu can also have a submenu. This way we can place similar commands into groups. For example we can place commands that hide/show various toolbars like personal bar, address bar, status bar or navigation bar into a submenu called toolbars. Within a menu, we can seperate commands with a separator. It is a simple line. It is common practice to separate commands like New, Open, Save from commands like Print, Print preview with a single separator. In our example we will see, how we can create submenus and menu separators. 
- submenu.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. In this example, we create a submenu and a menu  
  8. separator.  
  9.   
  10. author: Jan Bodnar  
  11. website: www.zetcode.com  
  12. last modified: April 2018  
  13. """  
  14.   
  15. import wx  
  16.   
  17.   
  18. class Example(wx.Frame):  
  19.   
  20.     def __init__(self, *args, **kwargs):  
  21.         super(Example, self).__init__(*args, **kwargs)  
  22.   
  23.         self.InitUI()  
  24.   
  25.     def InitUI(self):  
  26.   
  27.         menubar = wx.MenuBar()  
  28.   
  29.         fileMenu = wx.Menu()  
  30.         fileMenu.Append(wx.ID_NEW, '&New')  
  31.         fileMenu.Append(wx.ID_OPEN, '&Open')  
  32.         fileMenu.Append(wx.ID_SAVE, '&Save')  
  33.         fileMenu.AppendSeparator()  
  34.   
  35.         imp = wx.Menu()  
  36.         imp.Append(wx.ID_ANY, 'Import newsfeed list...')  
  37.         imp.Append(wx.ID_ANY, 'Import bookmarks...')  
  38.         imp.Append(wx.ID_ANY, 'Import mail...')  
  39.   
  40.         fileMenu.AppendMenu(wx.ID_ANY, 'I&mport', imp)  
  41.   
  42.         qmi = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+W')  
  43.         fileMenu.AppendItem(qmi)  
  44.   
  45.         self.Bind(wx.EVT_MENU, self.OnQuit, qmi)  
  46.   
  47.         menubar.Append(fileMenu, '&File')  
  48.         self.SetMenuBar(menubar)  
  49.   
  50.         self.SetSize((350250))  
  51.         self.SetTitle('Submenu')  
  52.         self.Centre()  
  53.   
  54.     def OnQuit(self, e):  
  55.         self.Close()  
  56.   
  57.   
  58. def main():  
  59.   
  60.     app = wx.App()  
  61.     ex = Example(None)  
  62.     ex.Show()  
  63.     app.MainLoop()  
  64.   
  65.   
  66. if __name__ == '__main__':  
  67.     main()  
In the above example, we create New, Open, and Save standard menu items. These are separated from a submenu with a horizontal separator. A submenu has additional three menu items. 
  1. fileMenu.Append(wx.ID_NEW, '&New')  
  2. fileMenu.Append(wx.ID_OPEN, '&Open')  
  3. fileMenu.Append(wx.ID_SAVE, '&Save')  
Here we have three common menu items: New, Open, and Save. 
  1. fileMenu.AppendSeparator()  
A menu separator is appended with the AppendSeparator() method. 
  1. imp = wx.Menu()  
  2. imp.Append(wx.ID_ANY, 'Import newsfeed list...')  
  3. imp.Append(wx.ID_ANY, 'Import bookmarks...')  
  4. imp.Append(wx.ID_ANY, 'Import mail...')  
  5.   
  6. fileMenu.AppendMenu(wx.ID_ANY, 'I&mport', imp)  
A submenu is also a wx.Menu. Three menu items are appended to the menu. The submenu is appended to the file menu with the AppenMenu() method: 


Check menu item 
There are tree kinds of menu items: 
* Normal item
* Check item
* Radio item

In the following example, we will demonstrate the check menu item. A check menu item is visually represented by a tick in the menu: 
- checkmenu_item.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. This example creates a checked  
  8. menu item.  
  9.   
  10. author: Jan Bodnar  
  11. website: www.zetcode.com  
  12. last modified: April 2018  
  13. """  
  14.   
  15. import wx  
  16.   
  17.   
  18. class Example(wx.Frame):  
  19.   
  20.     def __init__(self, *args, **kwargs):  
  21.         super(Example, self).__init__(*args, **kwargs)  
  22.   
  23.         self.InitUI()  
  24.   
  25.     def InitUI(self):  
  26.   
  27.         menubar = wx.MenuBar()  
  28.         viewMenu = wx.Menu()  
  29.   
  30.         self.shst = viewMenu.Append(wx.ID_ANY, 'Show statusbar',  
  31.             'Show Statusbar', kind=wx.ITEM_CHECK)  
  32.         self.shtl = viewMenu.Append(wx.ID_ANY, 'Show toolbar',  
  33.             'Show Toolbar', kind=wx.ITEM_CHECK)  
  34.   
  35.         viewMenu.Check(self.shst.GetId(), True)  
  36.         viewMenu.Check(self.shtl.GetId(), True)  
  37.   
  38.         self.Bind(wx.EVT_MENU, self.ToggleStatusBar, self.shst)  
  39.         self.Bind(wx.EVT_MENU, self.ToggleToolBar, self.shtl)  
  40.   
  41.         menubar.Append(viewMenu, '&View')  
  42.         self.SetMenuBar(menubar)  
  43.   
  44.         self.toolbar = self.CreateToolBar()  
  45.         self.toolbar.AddTool(1'', wx.Bitmap('texit.png'))  
  46.         self.toolbar.Realize()  
  47.   
  48.         self.statusbar = self.CreateStatusBar()  
  49.         self.statusbar.SetStatusText('Ready')  
  50.   
  51.         self.SetSize((450350))  
  52.         self.SetTitle('Check menu item')  
  53.         self.Centre()  
  54.   
  55.   
  56.     def ToggleStatusBar(self, e):  
  57.   
  58.         if self.shst.IsChecked():  
  59.             self.statusbar.Show()  
  60.         else:  
  61.             self.statusbar.Hide()  
  62.   
  63.     def ToggleToolBar(self, e):  
  64.   
  65.         if self.shtl.IsChecked():  
  66.             self.toolbar.Show()  
  67.         else:  
  68.             self.toolbar.Hide()  
  69.   
  70.   
  71. def main():  
  72.   
  73.     app = wx.App()  
  74.     ex = Example(None)  
  75.     ex.Show()  
  76.     app.MainLoop()  
  77.   
  78.   
  79. if __name__ == '__main__':  
  80.     main()  
We have a view menu, where we have two check menu items. These two menu items will show and hide a statusbar and a toolbar. If we want to append a check menu item, we set a kind parameter to wx.ITEM_CHECK. The default parameter is wx.ITEM_NORMAL. The Append() method returns a wx.MenuItem

When the application starts, both statusbar and toolbar are visible. So we check both menu items with the Check() method. We show or hide the statusbar according to the state of the check menu item. We find out the state of the check menu item with the IsChecked() method. Same with toolbar: 


Context menu 
A context menu is a list of commands that appears under some context. For example, in a Firefox web browser, when we right click on a web page, we get a context menu. Here we can reload a page, go back or view page source. If we right click on a toolbar, we get another context menu for managing toolbars. Context menus are sometimes called popup menus
- context_menu.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. In this example, we create a context menu.  
  8.   
  9. author: Jan Bodnar  
  10. website: www.zetcode.com  
  11. last modified: April 2018  
  12. """  
  13.   
  14. import wx  
  15.   
  16. class MyPopupMenu(wx.Menu):  
  17.   
  18.     def __init__(self, parent):  
  19.         super(MyPopupMenu, self).__init__()  
  20.   
  21.         self.parent = parent  
  22.   
  23.         mmi = wx.MenuItem(self, wx.NewId(), 'Minimize')  
  24.         self.Append(mmi)  
  25.         self.Bind(wx.EVT_MENU, self.OnMinimize, mmi)  
  26.   
  27.         cmi = wx.MenuItem(self, wx.NewId(), 'Close')  
  28.         self.Append(cmi)  
  29.         self.Bind(wx.EVT_MENU, self.OnClose, cmi)  
  30.   
  31.   
  32.     def OnMinimize(self, e):  
  33.         self.parent.Iconize()  
  34.   
  35.     def OnClose(self, e):  
  36.         self.parent.Close()  
  37.   
  38.   
  39. class Example(wx.Frame):  
  40.   
  41.     def __init__(self, *args, **kwargs):  
  42.         super(Example, self).__init__(*args, **kwargs)  
  43.   
  44.         self.InitUI()  
  45.   
  46.     def InitUI(self):  
  47.   
  48.         self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)  
  49.   
  50.         self.SetSize((350250))  
  51.         self.SetTitle('Context menu')  
  52.         self.Centre()  
  53.   
  54.     def OnRightDown(self, e):  
  55.         self.PopupMenu(MyPopupMenu(self), e.GetPosition())  
  56.   
  57.   
  58. def main():  
  59.   
  60.     app = wx.App()  
  61.     ex = Example(None)  
  62.     ex.Show()  
  63.     app.MainLoop()  
  64.   
  65.   
  66. if __name__ == '__main__':  
  67.     main()  
In the example, we create a context menu for the main window. It has two items. One will minimize the application, the other one will terminate it. We create a separate wx.Menu class. A menu item is created and appended to the context menu. An event handler is binded to this menu item: 
  1. self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)  
If we right click on the frame, we call the OnRightDown() method. For this, we use the wx.EVT_RIGHT_DOWN event binder. In the OnRightDown() method, we call the PopupMenu() method. This method shows the context menu. The first parameter is the menu to be shown. The second parameter is the position, where the context menu appears. The context menus appear at the point of the mouse cursor. To get the actual mouse position, we call the GetPosition() method of the supplied event object: 


Toolbars 
Menus group all commands that we can use in an application. Toolbars provide a quick access to the most frequently used commands. To create a toolbar, we call the CreateToolBar() method of the frame widget. 
toolbar.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. """  
  5. ZetCode wxPython tutorial  
  6.   
  7. This example creates a simple toolbar.  
  8.   
  9. author: Jan Bodnar  
  10. website: www.zetcode.com  
  11. last modified: April 2018  
  12. """  
  13.   
  14. import wx  
  15.   
  16.   
  17. class Example(wx.Frame):  
  18.   
  19.     def __init__(self, *args, **kwargs):  
  20.         super(Example, self).__init__(*args, **kwargs)  
  21.   
  22.         self.InitUI()  
  23.   
  24.     def InitUI(self):  
  25.   
  26.         toolbar = self.CreateToolBar()  
  27.         qtool = toolbar.AddTool(wx.ID_ANY, 'Quit', wx.Bitmap('texit.png'))  
  28.         toolbar.Realize()  
  29.   
  30.         self.Bind(wx.EVT_TOOL, self.OnQuit, qtool)  
  31.   
  32.         self.SetSize((350250))  
  33.         self.SetTitle('Simple toolbar')  
  34.         self.Centre()  
  35.   
  36.     def OnQuit(self, e):  
  37.         self.Close()  
  38.   
  39.   
  40. def main():  
  41.   
  42.     app = wx.App()  
  43.     ex = Example(None)  
  44.     ex.Show()  
  45.     app.MainLoop()  
  46.   
  47.   
  48. if __name__ == '__main__':  
  49.     main()  
In our example, we have a toolbar with one tool. The tool will close the application, when we click on it. We create a toolbar. By default, the toolbar is horizontal, has no borders and displays icons. To create a toolbar tool, we call the AddTool() method. The second parameter is the tool's label, the third is the tool's image. Note that the label is not visible, because the default style shows only icons: 
  1. qtool = toolbar.AddTool(wx.ID_ANY, 'Quit', wx.Bitmap('texit.png'))  
After we have put our items to the toolbar, we call the Realize() method. Calling this method is not obligatory on Linux. On windows it is. To handle toolbar events, we use the wx.EVT_TOOL event binder: 
  1. self.Bind(wx.EVT_TOOL, self.OnQuit, qtool)  


If we want to create more than one toolbar, we must do it differently. 
toolbars.py 
  1. #!/usr/bin/env python3  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. '''  
  5. ZetCode wxPython tutorial  
  6.   
  7. In this example, we create two horizontal  
  8. toolbars.  
  9.   
  10. author: Jan Bodnar  
  11. website: www.zetcode.com  
  12. last modified: April 2018  
  13. '''  
  14.   
  15. import wx  
  16.   
  17.   
  18. class Example(wx.Frame):  
  19.   
  20.     def __init__(self, *args, **kwargs):  
  21.         super(Example, self).__init__(*args, **kwargs)  
  22.   
  23.         self.InitUI()  
  24.   
  25.     def InitUI(self):  
  26.   
  27.         vbox = wx.BoxSizer(wx.VERTICAL)  
  28.   
  29.         toolbar1 = wx.ToolBar(self)  
  30.         toolbar1.AddTool(wx.ID_ANY, '', wx.Bitmap('tnew.png'))  
  31.         toolbar1.AddTool(wx.ID_ANY, '', wx.Bitmap('topen.png'))  
  32.         toolbar1.AddTool(wx.ID_ANY, '', wx.Bitmap('tsave.png'))  
  33.         toolbar1.Realize()  
  34.   
  35.         toolbar2 = wx.ToolBar(self)  
  36.         qtool = toolbar2.AddTool(wx.ID_EXIT, '', wx.Bitmap('texit.png'))  
  37.         toolbar2.Realize()  
  38.   
  39.         vbox.Add(toolbar1, 0, wx.EXPAND)  
  40.         vbox.Add(toolbar2, 0, wx.EXPAND)  
  41.   
  42.         self.Bind(wx.EVT_TOOL, self.OnQuit, qtool)  
  43.   
  44.         self.SetSizer(vbox)  
  45.   
  46.         self.SetSize((350250))  
  47.         self.SetTitle('Toolbars')  
  48.         self.Centre()  
  49.   
  50.     def OnQuit(self, e):  
  51.         self.Close()  
  52.   
  53.   
  54. def main():  
  55.   
  56.     app = wx.App()  
  57.     ex = Example(None)  
  58.     ex.Show()  
  59.     app.MainLoop()  
  60.   
  61.   
  62. if __name__ == '__main__':  
  63.     main()  
In the above example, we create two horizontal toolbars. We create two toolbar objects. And put them into a vertical box. 


Enable & disable 
In the following example we show how we can enable and disable toolbar buttons. We also add a separator line. 
undo_redo.py 
  1. #!/usr/bin/env python3  
  2. #!/usr/bin/env python3  
  3. # -*- coding: utf-8 -*-  
  4.   
  5. """  
  6. ZetCode wxPython tutorial  
  7.   
  8. In this example, we create two horizontal  
  9. toolbars.  
  10.   
  11. author: Jan Bodnar  
  12. website: www.zetcode.com  
  13. last modified: April 2018  
  14. """  
  15.   
  16. import wx  
  17.   
  18. class Example(wx.Frame):  
  19.   
  20.     def __init__(self, *args, **kwargs):  
  21.         super(Example, self).__init__(*args, **kwargs)  
  22.   
  23.         self.InitUI()  
  24.   
  25.     def InitUI(self):  
  26.   
  27.         self.count = 5  
  28.   
  29.         self.toolbar = self.CreateToolBar()  
  30.         tundo = self.toolbar.AddTool(wx.ID_UNDO, '', wx.Bitmap('undo-26.png'))  
  31.         tredo = self.toolbar.AddTool(wx.ID_REDO, '', wx.Bitmap('redo-26.png'))  
  32.         self.toolbar.EnableTool(wx.ID_REDO, False)  
  33.         self.toolbar.AddSeparator()  
  34.         texit = self.toolbar.AddTool(wx.ID_EXIT, '', wx.Bitmap('exit-26.png'))  
  35.         self.toolbar.Realize()  
  36.   
  37.         self.Bind(wx.EVT_TOOL, self.OnQuit, texit)  
  38.         self.Bind(wx.EVT_TOOL, self.OnUndo, tundo)  
  39.         self.Bind(wx.EVT_TOOL, self.OnRedo, tredo)  
  40.   
  41.         self.SetSize((350250))  
  42.         self.SetTitle('Undo redo')  
  43.         self.Centre()  
  44.   
  45.     def OnUndo(self, e):  
  46.         if self.count > 1 and self.count <= 5:  
  47.             self.count = self.count - 1  
  48.   
  49.         if self.count == 1:  
  50.             self.toolbar.EnableTool(wx.ID_UNDO, False)  
  51.   
  52.         if self.count == 4:  
  53.             self.toolbar.EnableTool(wx.ID_REDO, True)  
  54.   
  55.         self.SetTitle("Count={:,d}".format(self.count))  
  56.   
  57.     def OnRedo(self, e):  
  58.         if self.count < 5 and self.count >= 1:  
  59.             self.count = self.count + 1              
  60.   
  61.         if self.count == 5:  
  62.             self.toolbar.EnableTool(wx.ID_REDO, False)  
  63.   
  64.         if self.count == 2:  
  65.             self.toolbar.EnableTool(wx.ID_UNDO, True)  
  66.   
  67.         self.SetTitle("Count={:,d}".format(self.count))  
  68.   
  69.   
  70.     def OnQuit(self, e):  
  71.         self.Close()  
  72.   
  73.   
  74. def main():  
  75.   
  76.     app = wx.App()  
  77.     ex = Example(None)  
  78.     ex.Show()  
  79.     app.MainLoop()  
  80.   
  81.   
  82. if __name__ == '__main__':  
  83.     main()  
In our example, we have three toolbar buttons. One button is for exiting the application. The other two buttons are undo and redo buttons. They simulate undo/redo functionality in an application. (For a real example, see tips and tricks) We have 4 changes. The undo and redo buttons are disabled accordingly. 

In the beginning, the redo button is disabled. We do it by calling the EnableTool() method. We can create some logical groups within a toolbar. We can separate various groups of buttons by a small vertical line. To do this, we call the AddSeparator() method. 


Supplement 
Next - Layout management in wxPython

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...