При использовании Python API KiCAD для pcbnew вы можете показать диалог, используя следующий фрагмент
show_wx_dialog_example.py
# Show info dialog
dlg = wx.MessageDialog(None, "Please select one or multiple footprints!\n...or use Ctrl+A to select everything.", "No footprints selected", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()Обратите внимание, что вам нужно
import_wx.py
import wxв начале вашего плагина.
Этот код покажет следующий диалог:

Полный пример плагина:
DialogExamplePlugin.py
#!/usr/bin/env python
import pcbnew
import wx
class DialogExamplePlugin(pcbnew.ActionPlugin):
def defaults(self):
self.name = "Show dialog example"
self.category = "A descriptive category name"
self.description = "A description of the plugin and what it does"
self.show_toolbar_button = False # Optional, defaults to False
def Run(self):
dlg = wx.MessageDialog(None, "Please select one or multiple footprints!\n...or use Ctrl+A to select everything.", "No footprints selected", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
DialogExamplePlugin().register() # Instantiate and register to PcbnewВы можете разместить этот плагин, например, в
kicad_plugin_path.txt
~/.local/share/kicad/7.0/scripting/plugins/DialogExamplePlugin.pyНе забудьте обновить плагины из меню pcbnew.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow