pyipcore 0.4.8__tar.gz → 0.4.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyipcore
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: (PyQt5 based) Create "Ipcore" from verilog(Need iverilog). Provide "Param Value" and "Port Control" function. This kind of IpCore is not safe, only for convenience
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Operating System :: Microsoft :: Windows
12
12
  Requires-Python: >=3
13
13
  Requires-Dist: PyQt5
14
+ Requires-Dist: QScintilla
14
15
  Requires-Dist: reft==0.1.0
15
16
  Requires-Dist: pyverilog==1.3.0
16
17
  Requires-Dist: rbpop==0.1.2
@@ -6,6 +6,10 @@ from PyQt5.QtCore import QThread
6
6
  from reft import *
7
7
  from files3 import files, F3False
8
8
 
9
+ VERSION = "0.4.8"
10
+ GITEE_URL = "https://gitee.com/eagle-s_baby/pyipcore"
11
+ APP_NAME = "Py IP-Core Wizard"
12
+
9
13
  IPC_SUFFIX = '.ipc'
10
14
 
11
15
  V_SUFFIXS = ['.v', '.sv']
@@ -1,3 +1,4 @@
1
+ from PyQt5.QtGui import QFont, QColor
1
2
  from pyipcore.ui_main import GUI_Main, QApplication, QMessageBox
2
3
  import sys
3
4
 
@@ -7,7 +7,7 @@ from PyQt5.QtGui import QIcon, QFont, QTextDocument, QTextCursor
7
7
  from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox, QWidget, QMainWindow, QComboBox, QLineEdit, QCheckBox, QSizePolicy, QStyledItemDelegate, QMenu, QAction, QLabel, \
8
8
  QFrame, QPushButton, QGridLayout, QHBoxLayout, QVBoxLayout, QDialog, QListWidgetItem
9
9
 
10
- from pyipcore.ui_utils import PopWarn, PopError, PopInfo
10
+ from pyipcore.ui_utils import PopWarn, PopError, PopInfo, QVerilogEdit
11
11
  from pyipcore.ipc_utils import *
12
12
 
13
13
  from PyQt5.QtWidgets import QInputDialog
@@ -21,6 +21,8 @@ class GUI_IPCreator(QWidget):
21
21
  self.ui = Ui_Form()
22
22
  self.ui.setupUi(self)
23
23
 
24
+ self.load_current_size()
25
+
24
26
  self.fpath = None
25
27
  self._save_flag = False
26
28
  self.ipcore = None
@@ -30,12 +32,34 @@ class GUI_IPCreator(QWidget):
30
32
 
31
33
  self.reset_signals()
32
34
 
35
+ self.reset_ptxt_xcs()
36
+
33
37
  self.last_text = ""
34
38
 
39
+ def reset_ptxt_xcs(self):
40
+ """
41
+ 重置代码显示区域为VerilogEditor
42
+ """
43
+ self.ui.horizontalLayout.removeWidget(self.ui.text_code)
44
+ self.ui.text_code = QVerilogEdit(self)
45
+ self.ui.text_code.setObjectName("text_code")
46
+ sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
47
+ sizePolicy.setHorizontalStretch(30)
48
+ sizePolicy.setVerticalStretch(0)
49
+ sizePolicy.setHeightForWidth(self.ui.text_code.sizePolicy().hasHeightForWidth())
50
+ self.ui.text_code.setSizePolicy(sizePolicy)
51
+ self.ui.text_code.setReadOnly(False)
52
+ self.ui.horizontalLayout.addWidget(self.ui.text_code)
53
+
54
+ self.ui.text_code.setUserTextChanged(self._text_changed)
55
+
56
+ def _text_changed(self):
57
+ self.save_flag = True
58
+
35
59
  @property
36
60
  def save_flag(self):
37
61
  if self._save_flag is False:
38
- current_text = self.ui.text_code.toPlainText()
62
+ current_text = self.ui.text_code.text()
39
63
  if current_text != self.last_text:
40
64
  self._save_flag = True # 需要保存
41
65
  return self._save_flag
@@ -44,7 +68,7 @@ class GUI_IPCreator(QWidget):
44
68
  def save_flag(self, value):
45
69
  self._save_flag = value
46
70
  if value is False:
47
- self.last_text = self.ui.text_code.toPlainText()
71
+ self.last_text = self.ui.text_code.text()
48
72
 
49
73
  @property
50
74
  def ftype(self):
@@ -91,12 +115,19 @@ class GUI_IPCreator(QWidget):
91
115
  return
92
116
  event.accept()
93
117
 
118
+
119
+ def load_current_size(self):
120
+ f = files(os.getcwd(), '.prefer')
121
+ size = f["window_size"]
122
+ if size:
123
+ self.setFixedSize(size)
124
+
94
125
  def undo(self):
95
126
  if len(self.undo_stack) == 0:
96
127
  PopWarn("Warn", "Nothing to undo")
97
128
  return
98
- self.redo_stack.append(self.ui.text_code.toPlainText())
99
- self.ui.text_code.setPlainText(self.undo_stack.pop())
129
+ self.redo_stack.append(self.ui.text_code.text())
130
+ self.ui.text_code.setText(self.undo_stack.pop())
100
131
  if len(self.redo_stack) > MAX_UNDO_REDO:
101
132
  self.redo_stack.pop(0)
102
133
 
@@ -106,8 +137,8 @@ class GUI_IPCreator(QWidget):
106
137
  if len(self.redo_stack) == 0:
107
138
  PopWarn("Warn", "Nothing to redo")
108
139
  return
109
- self.undo_stack.append(self.ui.text_code.toPlainText())
110
- self.ui.text_code.setPlainText(self.redo_stack.pop())
140
+ self.undo_stack.append(self.ui.text_code.text())
141
+ self.ui.text_code.setText(self.redo_stack.pop())
111
142
  if len(self.undo_stack) > MAX_UNDO_REDO:
112
143
  self.undo_stack.pop(0)
113
144
 
@@ -129,7 +160,7 @@ class GUI_IPCreator(QWidget):
129
160
  self.ui.list_var.addItem(key)
130
161
 
131
162
  def open_file(self):
132
- f = files(os.getcwd())
163
+ f = files(os.getcwd(), '.prefer')
133
164
  fdir = f["creator_last_dir"]
134
165
  fdir = os.path.abspath(fdir) if fdir else os.getcwd()
135
166
  # open .v or .ipc
@@ -150,12 +181,12 @@ class GUI_IPCreator(QWidget):
150
181
  return
151
182
 
152
183
  self.ipcore = IpCore(fdir, fname)
153
- self.ui.text_code.setPlainText(self.ipcore.content)
184
+ self.ui.text_code.setText(self.ipcore.content)
154
185
  self.reload_list()
155
186
  elif ftype in V_SUFFIXS:
156
187
  # load into text-code
157
188
  with open(fpath, encoding='utf-8') as f:
158
- self.ui.text_code.setPlainText(f.read())
189
+ self.ui.text_code.setText(f.read())
159
190
  self.ipcore = None
160
191
  self.ui.list_var.clear()
161
192
  else:
@@ -163,12 +194,12 @@ class GUI_IPCreator(QWidget):
163
194
  self.fpath = None
164
195
 
165
196
  # save last fdir
166
- f = files(os.getcwd())
197
+ f = files(os.getcwd(), '.prefer')
167
198
  f["creator_last_dir"] = fdir
168
199
 
169
200
  def close_file(self):
170
- if self.fpath is None:
171
- PopError("错误", "未打开任何文件")
201
+ if self.fpath is None and self.save_flag is False:
202
+ PopError("错误", "没有可以保存的内容")
172
203
  return
173
204
  if self.save_flag:
174
205
  _ = QMessageBox.question(self, "关闭文件", "是否保存文件?", QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
@@ -179,14 +210,14 @@ class GUI_IPCreator(QWidget):
179
210
  return
180
211
  self.fpath = None
181
212
  self.ipcore = None
182
- self.ui.text_code.setPlainText("")
213
+ self.ui.text_code.setText("")
183
214
  self.ui.list_var.clear()
184
215
 
185
216
  def save_file(self):
186
217
  # save to .v or .ipc
187
- if self.fpath is None:
188
- PopError("错误", "未打开任何文件")
189
- return
218
+ # if self.fpath is None and self.save_flag is False:
219
+ # PopError("错误", "没有可以保存的内容")
220
+ # return
190
221
  # ask save path
191
222
  fpath, _ = QFileDialog.getSaveFileName(self, "Save File", os.getcwd(), SAVE_TYPE)
192
223
  if fpath == "":
@@ -200,15 +231,15 @@ class GUI_IPCreator(QWidget):
200
231
  if ftype == IPC_SUFFIX:
201
232
  # save to ipc
202
233
  f = files(fdir, IPC_SUFFIX)
203
- f[fname] = self.ui.text_code.toPlainText()
234
+ f[fname] = self.ui.text_code.text()
204
235
  self.save_flag = False
205
236
  # reload for ipc
206
237
  self.ipcore = IpCore(fdir, fname)
207
- self.ui.text_code.setPlainText(self.ipcore.content)
238
+ self.ui.text_code.setText(self.ipcore.content)
208
239
  self.reload_list()
209
240
  elif ftype in V_SUFFIXS:
210
241
  with open(fpath, 'w', encoding='utf-8') as f:
211
- f.write(self.ui.text_code.toPlainText())
242
+ f.write(self.ui.text_code.text())
212
243
  self.save_flag = False
213
244
  else:
214
245
  PopError("错误", f"不支持的文件类型{ftype}")
@@ -217,9 +248,9 @@ class GUI_IPCreator(QWidget):
217
248
  return True
218
249
 
219
250
  def new_param(self):
220
- if self.fpath is None:
221
- PopError("错误", "未打开任何文件")
222
- return
251
+ # if self.fpath is None and self.save_flag is False:
252
+ # PopError("错误", "没有可以保存的内容")
253
+ # return
223
254
  # ask input: Name:str && Default:str at once
224
255
  name, ok = QInputDialog.getText(self, "新建参数", "参数名:")
225
256
  if not ok:
@@ -248,9 +279,9 @@ class GUI_IPCreator(QWidget):
248
279
  self.ui.list_var.addItem(name)
249
280
 
250
281
  def new_control(self):
251
- if self.fpath is None:
252
- PopError("错误", "未打开任何文件")
253
- return
282
+ # if self.fpath is None and self.save_flag is False:
283
+ # PopError("错误", "没有可以保存的内容")
284
+ # return
254
285
  # ask input: Name:str
255
286
  name, ok = QInputDialog.getText(self, "新建端口控制", "参数名:")
256
287
  if not ok:
@@ -280,7 +311,7 @@ class GUI_IPCreator(QWidget):
280
311
  PopError("错误", "未选中任何内容.请重试.")
281
312
  return
282
313
 
283
- txt = self.ui.text_code.toPlainText()
314
+ txt = self.ui.text_code.text()
284
315
 
285
316
  # add to undo_stack
286
317
  self.undo_stack.append(txt)
@@ -320,7 +351,7 @@ class GUI_IPCreator(QWidget):
320
351
  tar = f"${key}$\n"
321
352
 
322
353
  # replace
323
- self.ui.text_code.setPlainText(bef + tar + aft)
354
+ self.ui.text_code.setText(bef + tar + aft)
324
355
 
325
356
  self.save_flag = True
326
357
 
@@ -15,8 +15,13 @@ class Ui_Form(object):
15
15
  def setupUi(self, Form):
16
16
  Form.setObjectName("Form")
17
17
  Form.resize(960, 720)
18
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
19
+ sizePolicy.setHorizontalStretch(0)
20
+ sizePolicy.setVerticalStretch(0)
21
+ sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
22
+ Form.setSizePolicy(sizePolicy)
18
23
  Form.setMinimumSize(QtCore.QSize(960, 720))
19
- Form.setMaximumSize(QtCore.QSize(960, 720))
24
+ Form.setMaximumSize(QtCore.QSize(2560, 1440))
20
25
  font = QtGui.QFont()
21
26
  font.setFamily("Consolas")
22
27
  font.setPointSize(12)
@@ -29,11 +34,13 @@ class Ui_Form(object):
29
34
  self.horizontalLayout.setSpacing(5)
30
35
  self.horizontalLayout.setObjectName("horizontalLayout")
31
36
  self.frame = QtWidgets.QFrame(Form)
32
- sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
37
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
33
38
  sizePolicy.setHorizontalStretch(10)
34
39
  sizePolicy.setVerticalStretch(0)
35
40
  sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth())
36
41
  self.frame.setSizePolicy(sizePolicy)
42
+ self.frame.setMinimumSize(QtCore.QSize(320, 0))
43
+ self.frame.setMaximumSize(QtCore.QSize(320, 16777215))
37
44
  self.frame.setFrameShape(QtWidgets.QFrame.Box)
38
45
  self.frame.setFrameShadow(QtWidgets.QFrame.Plain)
39
46
  self.frame.setObjectName("frame")
@@ -129,7 +136,7 @@ class Ui_Form(object):
129
136
 
130
137
  def retranslateUi(self, Form):
131
138
  _translate = QtCore.QCoreApplication.translate
132
- Form.setWindowTitle(_translate("Form", "IpCore Creator Wizade"))
139
+ Form.setWindowTitle(_translate("Form", "Py IP-Core Creator Wizard"))
133
140
  self.groupBox.setTitle(_translate("Form", "File"))
134
141
  self.btn_open.setText(_translate("Form", "Open file"))
135
142
  self.btn_save.setText(_translate("Form", "Save file"))
@@ -137,4 +144,4 @@ class Ui_Form(object):
137
144
  self.groupBox_2.setTitle(_translate("Form", "New"))
138
145
  self.btn_new_param.setText(_translate("Form", "New IP Parameter"))
139
146
  self.btn_new_control.setText(_translate("Form", "New Port Control"))
140
- import pyipcore.icon_rc
147
+ import icon_rc
@@ -5,11 +5,11 @@ from pyipcore.ipcore import IpCore, VAR_PARAM_TYPE, VAR_PORT_TYPE
5
5
  from PyQt5 import QtGui, QtWidgets
6
6
  from PyQt5.QtCore import Qt, pyqtSignal
7
7
  from PyQt5.QtCore import QStringListModel, QAbstractListModel, QVariant, QModelIndex, QSize
8
- from PyQt5.QtGui import QIcon, QFont, QTextDocument, QTextCursor
8
+ from PyQt5.QtGui import QIcon, QFont, QTextDocument, QTextCursor, QPixmap
9
9
  from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox, QWidget, QMainWindow, QComboBox, QLineEdit, QCheckBox, QSizePolicy, QStyledItemDelegate, QMenu, QAction, QLabel, \
10
10
  QFrame, QPushButton, QGridLayout, QHBoxLayout, QVBoxLayout, QDialog, QSpacerItem, QScrollBar
11
11
  from pyipcore.ui_creater import GUI_IPCreator
12
- from pyipcore.ui_utils import PopWarn, PopError, PopInfo
12
+ from pyipcore.ui_utils import PopWarn, PopError, PopInfo, AboutDialog, QVerilogEdit
13
13
  from pyipcore.ipc_utils import *
14
14
  from files3 import files
15
15
 
@@ -160,11 +160,13 @@ class VarItemWidget(QWidget):
160
160
  spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
161
161
  self.vlayout.addItem(spacer)
162
162
 
163
+
163
164
  class GUI_Main(QMainWindow):
164
165
  def __init__(self):
165
166
  super(GUI_Main, self).__init__()
166
167
  self.ui = Ui_MainForm()
167
168
  self.ui.setupUi(self)
169
+ self.setWindowTitle(f"{APP_NAME} {VERSION}")
168
170
  self.load_current_size()
169
171
  self.ui.tab_sc.setCurrentIndex(0)
170
172
 
@@ -192,16 +194,13 @@ class GUI_Main(QMainWindow):
192
194
  self.ui.ptxt_ic.setTabStopWidth(4 * 4)
193
195
  self.reset_signals()
194
196
 
197
+ # reset ptxt to QVerilogEdit
198
+ self.reset_ptxt_xcs()
199
+
200
+
195
201
  def reset_signals(self):
196
202
  """
197
- menu_file
198
- action_file_open
199
- ...close
200
- ...quit
201
- menu_edit
202
- ...lib_path
203
- menu_proj
204
- ...export
203
+ 重新绑定信号槽
205
204
  :return:
206
205
  """
207
206
  self.ui.action_file_open.triggered.connect(self.open_file)
@@ -210,9 +209,34 @@ class GUI_Main(QMainWindow):
210
209
  self.ui.action_file_quit.triggered.connect(self.close)
211
210
  self.ui.action_proj_export.triggered.connect(self.export_proj)
212
211
  self.ui.action_tool_creator.triggered.connect(self.open_creator)
212
+ self.ui.action_tool_creator.triggered.connect(self.open_creator)
213
+ self.ui.action_help_readme.triggered.connect(lambda: PopInfo("Readme", "请参考README.md"))
214
+ self.ui.action_help_about.triggered.connect(self.show_about)
213
215
 
214
216
  self.worker.icode_update.connect(self._update_icode)
215
217
 
218
+ def reset_ptxt_xcs(self):
219
+ """
220
+ 重置代码显示区域为VerilogEditor
221
+ """
222
+ self.ui.horizontalLayout_3.removeWidget(self.ui.ptxt_rc)
223
+ self.ui.ptxt_rc = QVerilogEdit(self.ui.tab_rc)
224
+ self.ui.ptxt_rc.setReadOnly(True)
225
+ self.ui.ptxt_rc.setObjectName("ptxt_rc")
226
+ self.ui.horizontalLayout_3.addWidget(self.ui.ptxt_rc)
227
+ self.ui.horizontalLayout_4.removeWidget(self.ui.ptxt_cc)
228
+ self.ui.ptxt_cc = QVerilogEdit(self.ui.tab_cc)
229
+ self.ui.ptxt_cc.setReadOnly(True)
230
+ self.ui.ptxt_cc.setObjectName("ptxt_cc")
231
+ self.ui.horizontalLayout_4.addWidget(self.ui.ptxt_cc)
232
+ self.ui.horizontalLayout_5.removeWidget(self.ui.ptxt_ic)
233
+ self.ui.ptxt_ic = QVerilogEdit(self.ui.tab_ic)
234
+ self.ui.ptxt_ic.setReadOnly(True)
235
+ self.ui.ptxt_ic.setObjectName("ptxt_ic")
236
+ self.ui.horizontalLayout_5.addWidget(self.ui.ptxt_ic)
237
+
238
+
239
+
216
240
  def open_creator(self):
217
241
  # open as dialog
218
242
  if self.ip_creator is not None:
@@ -235,21 +259,21 @@ class GUI_Main(QMainWindow):
235
259
  self.ipcore.build(**self.var_dict)
236
260
 
237
261
  # update cc ic
238
- self.ui.ptxt_cc.setPlainText(self.ipcore.built)
262
+ self.ui.ptxt_cc.setText(self.ipcore.built)
239
263
  self.worker.add(self.ipcore.GetICode)
240
- self.ui.ptxt_ic.setPlainText('loading...')
264
+ self.ui.ptxt_ic.setText('loading...')
241
265
 
242
266
  def _update_icode(self, txt):
243
267
  if txt.startswith("$ERROR"):
244
268
  PopError("Error Config:", "Pls check and try again. Detail in 'InstCode'")
245
- self.ui.ptxt_ic.setPlainText(txt[6:])
269
+ self.ui.ptxt_ic.setText(txt[6:])
246
270
  return
247
- self.ui.ptxt_ic.setPlainText(txt)
271
+ self.ui.ptxt_ic.setText(txt)
248
272
 
249
273
 
250
274
  def open_file(self):
251
- f = files(os.getcwd())
252
- fdir = f["last_dir"]
275
+ f = files(os.getcwd(), '.prefer')
276
+ fdir = f["last_ipc_dir"]
253
277
  fdir = os.path.abspath(fdir) if fdir else os.getcwd()
254
278
  path = QFileDialog.getOpenFileName(self, "选择IP核文件", fdir, f"IP核文件 (*{IPC_SUFFIX})")[0]
255
279
  if not path:
@@ -266,9 +290,9 @@ class GUI_Main(QMainWindow):
266
290
  return
267
291
 
268
292
  self.ipcore = IpCore(fdir, fname)
269
- self.ui.ptxt_rc.setPlainText(get)
270
- self.ui.ptxt_cc.setPlainText("")
271
- self.ui.ptxt_ic.setPlainText("")
293
+ self.ui.ptxt_rc.setText(get)
294
+ self.ui.ptxt_cc.setText("")
295
+ self.ui.ptxt_ic.setText("")
272
296
  self.ui.tab_sc.setCurrentIndex(0)
273
297
 
274
298
  # model
@@ -290,16 +314,16 @@ class GUI_Main(QMainWindow):
290
314
  self._enter_update_vars()
291
315
 
292
316
  # save last fdir
293
- f = files(os.getcwd())
294
- f["last_dir"] = fdir
317
+ f = files(os.getcwd(), '.prefer')
318
+ f["last_ipc_dir"] = fdir
295
319
 
296
320
  PopInfo("Info", "打开成功.")
297
321
 
298
322
  def close_file(self):
299
323
  self.ipcore = None
300
- self.ui.ptxt_rc.setPlainText("")
301
- self.ui.ptxt_cc.setPlainText("")
302
- self.ui.ptxt_ic.setPlainText("")
324
+ self.ui.ptxt_rc.setText("")
325
+ self.ui.ptxt_cc.setText("")
326
+ self.ui.ptxt_ic.setText("")
303
327
  self.var_widget.clearItems()
304
328
  self.ui.tab_sc.setCurrentIndex(0)
305
329
 
@@ -308,13 +332,13 @@ class GUI_Main(QMainWindow):
308
332
 
309
333
 
310
334
  def save_current_size(self):
311
- f = files(os.getcwd())
312
- f["prefered_size"] = self.size()
335
+ f = files(os.getcwd(), '.prefer')
336
+ f["window_size"] = self.size()
313
337
 
314
338
 
315
339
  def load_current_size(self):
316
- f = files(os.getcwd())
317
- size = f["prefered_size"]
340
+ f = files(os.getcwd(), '.prefer')
341
+ size = f["window_size"]
318
342
  if size:
319
343
  self.resize(size)
320
344
 
@@ -322,7 +346,7 @@ class GUI_Main(QMainWindow):
322
346
  if self.ipcore is None:
323
347
  PopWarn("警告", "请先打开一个IP核文件.")
324
348
  return
325
- f = files(os.getcwd())
349
+ f = files(os.getcwd(), '.prefer')
326
350
  fdir = f["last_export_dir"]
327
351
  fdir = os.path.abspath(fdir) if fdir else os.getcwd()
328
352
  path = QFileDialog.getSaveFileName(self, "选择导出的verilog文件", fdir, VERILOG_TYPE)[0]
@@ -337,10 +361,14 @@ class GUI_Main(QMainWindow):
337
361
  PopInfo("Info", "导出成功.")
338
362
 
339
363
  # save last fdir
340
- f = files(os.getcwd())
364
+ f = files(os.getcwd(), '.prefer')
341
365
  f["last_export_dir"] = fdir
342
366
 
343
367
 
368
+ def show_about(self):
369
+ about_dialog = AboutDialog(self)
370
+ about_dialog.exec_()
371
+
344
372
  if __name__ == '__main__':
345
373
  import sys
346
374
 
@@ -110,6 +110,7 @@ class Ui_MainForm(object):
110
110
  self.menu_proj = QtWidgets.QMenu(self.menubar)
111
111
  self.menu_proj.setObjectName("menu_proj")
112
112
  self.menu_tool = QtWidgets.QMenu(self.menubar)
113
+ self.menu_tool.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
113
114
  self.menu_tool.setObjectName("menu_tool")
114
115
  self.menu_help = QtWidgets.QMenu(self.menubar)
115
116
  self.menu_help.setObjectName("menu_help")
@@ -128,20 +129,33 @@ class Ui_MainForm(object):
128
129
  self.action_tool_creator.setObjectName("action_tool_creator")
129
130
  self.action_file_scs = QtWidgets.QAction(MainForm)
130
131
  self.action_file_scs.setObjectName("action_file_scs")
131
- self.action_readme = QtWidgets.QAction(MainForm)
132
- self.action_readme.setObjectName("action_readme")
133
- self.action_about = QtWidgets.QAction(MainForm)
134
- self.action_about.setObjectName("action_about")
132
+ self.action_help_readme = QtWidgets.QAction(MainForm)
133
+ self.action_help_readme.setObjectName("action_help_readme")
134
+ self.action_help_about = QtWidgets.QAction(MainForm)
135
+ self.action_help_about.setObjectName("action_help_about")
136
+ self.action_new_project = QtWidgets.QAction(MainForm)
137
+ self.action_new_project.setObjectName("action_new_project")
138
+ self.action_open_project = QtWidgets.QAction(MainForm)
139
+ self.action_open_project.setObjectName("action_open_project")
140
+ self.action_save_project = QtWidgets.QAction(MainForm)
141
+ self.action_save_project.setObjectName("action_save_project")
142
+ self.action_close_project = QtWidgets.QAction(MainForm)
143
+ self.action_close_project.setObjectName("action_close_project")
144
+ self.action_recent_projects = QtWidgets.QAction(MainForm)
145
+ self.action_recent_projects.setObjectName("action_recent_projects")
146
+ self.action_set_export_path = QtWidgets.QAction(MainForm)
147
+ self.action_set_export_path.setObjectName("action_set_export_path")
135
148
  self.menu_file.addAction(self.action_file_open)
136
149
  self.menu_file.addAction(self.action_file_close)
137
150
  self.menu_file.addSeparator()
138
151
  self.menu_file.addAction(self.action_file_scs)
152
+ self.menu_file.addAction(self.action_lib_path)
139
153
  self.menu_file.addSeparator()
140
154
  self.menu_file.addAction(self.action_file_quit)
141
155
  self.menu_proj.addAction(self.action_proj_export)
142
156
  self.menu_tool.addAction(self.action_tool_creator)
143
- self.menu_help.addAction(self.action_about)
144
- self.menu_help.addAction(self.action_readme)
157
+ self.menu_help.addAction(self.action_help_about)
158
+ self.menu_help.addAction(self.action_help_readme)
145
159
  self.menubar.addAction(self.menu_file.menuAction())
146
160
  self.menubar.addAction(self.menu_proj.menuAction())
147
161
  self.menubar.addAction(self.menu_tool.menuAction())
@@ -153,7 +167,7 @@ class Ui_MainForm(object):
153
167
 
154
168
  def retranslateUi(self, MainForm):
155
169
  _translate = QtCore.QCoreApplication.translate
156
- MainForm.setWindowTitle(_translate("MainForm", "IP Generator Wizard"))
170
+ MainForm.setWindowTitle(_translate("MainForm", "Py IP-Wizard"))
157
171
  self.gbox_var.setTitle(_translate("MainForm", "Variables"))
158
172
  self.tab_sc.setTabText(self.tab_sc.indexOf(self.tab_rc), _translate("MainForm", "RawCode"))
159
173
  self.tab_sc.setTabText(self.tab_sc.indexOf(self.tab_cc), _translate("MainForm", "CurrentCode"))
@@ -162,13 +176,19 @@ class Ui_MainForm(object):
162
176
  self.menu_proj.setTitle(_translate("MainForm", "项目"))
163
177
  self.menu_tool.setTitle(_translate("MainForm", "工具"))
164
178
  self.menu_help.setTitle(_translate("MainForm", "帮助"))
165
- self.action_file_open.setText(_translate("MainForm", "打开"))
166
- self.action_file_close.setText(_translate("MainForm", "关闭"))
167
- self.action_file_quit.setText(_translate("MainForm", "退出"))
168
- self.action_proj_export.setText(_translate("MainForm", "导出"))
169
- self.action_lib_path.setText(_translate("MainForm", "lib_path"))
170
- self.action_tool_creator.setText(_translate("MainForm", "Ip Creator Wizade"))
171
- self.action_file_scs.setText(_translate("MainForm", "保存尺寸"))
172
- self.action_readme.setText(_translate("MainForm", "帮助文档"))
173
- self.action_about.setText(_translate("MainForm", "关于"))
179
+ self.action_file_open.setText(_translate("MainForm", "打开 Py IP-Core"))
180
+ self.action_file_close.setText(_translate("MainForm", "关闭 Py IP-Core"))
181
+ self.action_file_quit.setText(_translate("MainForm", "退出程序"))
182
+ self.action_proj_export.setText(_translate("MainForm", "导出到..."))
183
+ self.action_lib_path.setText(_translate("MainForm", "设置上次打开目录为默认"))
184
+ self.action_tool_creator.setText(_translate("MainForm", "启动 Py IP-Core 新建向导"))
185
+ self.action_file_scs.setText(_translate("MainForm", "保存当前尺寸为默认值"))
186
+ self.action_help_readme.setText(_translate("MainForm", "帮助文档"))
187
+ self.action_help_about.setText(_translate("MainForm", "关于"))
188
+ self.action_new_project.setText(_translate("MainForm", "启动 Py IP-Project 新建向导"))
189
+ self.action_open_project.setText(_translate("MainForm", "打开 Py IP-Project"))
190
+ self.action_save_project.setText(_translate("MainForm", "保存 Py IP-Project"))
191
+ self.action_close_project.setText(_translate("MainForm", "关闭当前工程"))
192
+ self.action_recent_projects.setText(_translate("MainForm", "最近的项目"))
193
+ self.action_set_export_path.setText(_translate("MainForm", "设置导出路径"))
174
194
  import icon_rc
@@ -0,0 +1,225 @@
1
+ from PyQt5.QtCore import Qt, QUrl
2
+ from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QGridLayout, QPushButton, QSpacerItem, QSizePolicy, QApplication
3
+ from PyQt5.Qsci import QsciScintilla, QsciLexerVerilog, QsciAPIs
4
+ from PyQt5.QtGui import QIcon, QPixmap, QDesktopServices, QFont, QColor
5
+ from pyipcore.ipc_utils import VERSION, GITEE_URL, APP_NAME
6
+ from rbpop import WinManager, RbpopInfo, RbpopWarn, RbpopError
7
+ from threading import Thread
8
+ import winsound
9
+ import time
10
+ import re
11
+
12
+
13
+ class QVerilogEdit(QsciScintilla):
14
+ def __init__(self, parent=None, default_text=""):
15
+ super().__init__(parent)
16
+
17
+ # 创建 QScintilla 编辑器组件
18
+ self.lexer = QsciLexerVerilog(parent)
19
+
20
+ # 设置字体
21
+ self.editor_font = QFont("Consolas", 14, QFont.Bold)
22
+ self.editor_font.setFixedPitch(True)
23
+ self.lexer.setFont(self.editor_font)
24
+ self.setFont(self.editor_font)
25
+
26
+ # 设置 lexer 为 Verilog
27
+ self.setLexer(self.lexer)
28
+
29
+ # 设置编辑器的大小和位置
30
+ self.setGeometry(100, 100, 1400, 800)
31
+
32
+ # 设置文本
33
+ self.setText(default_text)
34
+
35
+ # Set editor edit attributes
36
+ self.set_editor_attributes()
37
+
38
+ self._user_text_changed = None
39
+
40
+ def set_editor_attributes(self):
41
+ self.setUtf8(True)
42
+ self.setMarginsFont(self.editor_font)
43
+ self.setMarginWidth(0, len(str(len(self.text().split('\n')))) * 20)
44
+ self.setMarginLineNumbers(0, True)
45
+
46
+ self.setEdgeMode(QsciScintilla.EdgeLine)
47
+ self.setEdgeColumn(100)
48
+ self.setEdgeColor(QColor(0, 0, 0))
49
+
50
+ self.setBraceMatching(QsciScintilla.StrictBraceMatch)
51
+
52
+ self.setIndentationsUseTabs(True)
53
+ self.setIndentationWidth(4)
54
+ self.setTabIndents(True)
55
+ self.setAutoIndent(True)
56
+ self.setBackspaceUnindents(True)
57
+ self.setTabWidth(4)
58
+
59
+ self.setCaretLineVisible(True)
60
+ self.setCaretLineBackgroundColor(QColor('#FFFFCD'))
61
+
62
+ self.setIndentationGuides(True)
63
+
64
+ self.setFolding(QsciScintilla.PlainFoldStyle)
65
+ self.setMarginWidth(2, 12)
66
+
67
+ self.setMarkerForegroundColor(QColor("#272727"), QsciScintilla.SC_MARKNUM_FOLDEROPENMID)
68
+ self.setAutoCompletionSource(QsciScintilla.AcsAll)
69
+ self.setAutoCompletionCaseSensitivity(True)
70
+ self.setAutoCompletionReplaceWord(False)
71
+ self.setAutoCompletionThreshold(1)
72
+ self.setAutoCompletionUseSingle(QsciScintilla.AcusExplicit)
73
+
74
+ self.__api = QsciAPIs(self.lexer)
75
+ auto_completions = ['module', 'endmodule', 'input', 'output', 'inout', 'wire', 'reg', 'assign',
76
+ 'always', 'posedge', 'negedge', 'if', 'else', 'begin', 'end',
77
+ 'case', 'endcase', 'default', 'for', 'while', 'repeat', 'forever',
78
+ 'initial', 'function', 'endfunction', 'task', 'endtask', 'logic', 'integer',
79
+ 'parameter', 'localparam', 'generate', 'endgenerate']
80
+ for word in auto_completions:
81
+ self.__api.add(word)
82
+ self.__api.prepare()
83
+ self.autoCompleteFromAll()
84
+
85
+ self.textChanged.connect(self.changed)
86
+
87
+ def changed(self):
88
+ self.setMarginWidth(0, len(str(len(self.text().split('\n')))) * 20)
89
+ if self._user_text_changed:
90
+ self._user_text_changed()
91
+
92
+ def setUserTextChanged(self, func):
93
+ self._user_text_changed = func
94
+
95
+
96
+
97
+ class BeepThread(Thread):
98
+ def __init__(self):
99
+ # 主程序退出后,子线程也退出
100
+ super().__init__(daemon=True)
101
+ self.tasks = []
102
+ self.flag = True
103
+
104
+ def Beep(self, freq, duration):
105
+ self.tasks.append((freq, duration))
106
+
107
+ def run(self):
108
+ while self.flag:
109
+ if not self.tasks:
110
+ time.sleep(0.2)
111
+ continue
112
+ freq, duration = self.tasks.pop(0)
113
+ winsound.Beep(freq, duration)
114
+
115
+ def stop(self):
116
+ self.flag = False
117
+
118
+
119
+ class BeepWinManager(WinManager):
120
+ def __init__(self):
121
+ super().__init__()
122
+ self.beep = BeepThread()
123
+ self.beep.start()
124
+
125
+ def add(self, win, freq, duration):
126
+ super().add(win)
127
+ self.beep.Beep(freq, duration)
128
+
129
+
130
+ _GLOBAL_WM = [None]
131
+
132
+
133
+ def QPop(pop_win_inst, freq=400, duration=100):
134
+ if _GLOBAL_WM[0] is None:
135
+ _GLOBAL_WM[0] = BeepWinManager()
136
+
137
+ _GLOBAL_WM[0].add(pop_win_inst, freq, duration)
138
+
139
+
140
+ def _pop_pre(title, msg):
141
+ msg = re.sub(r'(.{30})', r'\1\n', ' ' + msg)
142
+ _len = len(msg)
143
+ ct = 4000 + _len * 50
144
+ return title, msg, ct
145
+
146
+
147
+ def PopInfo(title, msg):
148
+ title, msg, ct = _pop_pre(title, msg)
149
+ QPop(RbpopInfo(msg, title, ct=ct, title_style='color:rgb(105,109,105);font-size:20px;', msg_style='color:rgb(65,98,65);font-size:20px;', close=True), 400, 300)
150
+
151
+
152
+ def PopWarn(title, msg):
153
+ title, msg, ct = _pop_pre(title, msg)
154
+ QPop(RbpopWarn(msg, title, ct=ct, title_style='color:rgb(105,125,85);font-size:20px;', msg_style='color:rgb(85,105,75);font-size:20px;', close=True), 600, 300)
155
+
156
+
157
+ def PopError(title, msg):
158
+ title, msg, ct = _pop_pre(title, msg)
159
+ QPop(RbpopError(msg, title, ct=ct, title_style='color:rgb(225,50,50);font-size:20px;', msg_style='color:rgb(185,50,50);font-size:20px;', close=True), 800, 300)
160
+
161
+
162
+ class AboutDialog(QDialog):
163
+ def __init__(self, parent=None):
164
+ super(AboutDialog, self).__init__(parent)
165
+ self.setWindowTitle(f"关于 {APP_NAME}")
166
+
167
+ # 创建布局
168
+ layout = QVBoxLayout()
169
+
170
+ # 创建图标标签
171
+ icon_label = QLabel(self)
172
+ icon = QIcon()
173
+ icon.addPixmap(QPixmap(":/icon/verilog.png"), QIcon.Normal, QIcon.Off)
174
+ icon_label.setPixmap(icon.pixmap(128, 128)) # 设置图标大小
175
+
176
+ # 创建文本标签
177
+ self.text_label = QLabel(self)
178
+ self.url_label = QLabel(self)
179
+ self.set_text() # 设置文本内容和链接
180
+ self.text_label.setWordWrap(True) # 开启文本换行
181
+ self.url_label.setTextInteractionFlags(Qt.TextBrowserInteraction) # 允许文本交互
182
+ font = QApplication.font("SIMHEI")
183
+ font.setPointSize(11) # 例如,设置字号为12,您可以根据需要调整这个值
184
+ self.text_label.setFont(font)
185
+ self.url_label.setFont(font)
186
+
187
+ # 创建按钮
188
+ button = QPushButton("确定", self)
189
+ button.setDefault(True) # 设置为默认按钮
190
+
191
+ # 创建网格布局并添加组件
192
+ grid_layout = QGridLayout()
193
+ grid_layout.addWidget(icon_label, 0, 0, 3, 1) # 图标跨越3行
194
+ grid_layout.addWidget(self.text_label, 0, 1, 1, 1) # 文本标签在第一行,第二列
195
+ grid_layout.addWidget(self.url_label, 1, 1, 1, 1) # URL标签在第二行,第二列
196
+ grid_layout.addWidget(button, 2, 1, 1, 1) # 按钮在第三行,第二列
197
+
198
+ # 添加水平间隔
199
+ spacer_item = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
200
+ grid_layout.addItem(spacer_item, 1, 0)
201
+
202
+ # 将网格布局添加到垂直布局
203
+ layout.addLayout(grid_layout)
204
+
205
+ # 设置对话框的布局
206
+ self.setLayout(layout)
207
+
208
+ # 连接按钮的点击事件
209
+ button.clicked.connect(self.close)
210
+
211
+ # 连接文本标签的链接激活事件
212
+ self.url_label.linkActivated.connect(self.open_url)
213
+
214
+ def set_text(self):
215
+ self.text_label.setText(f"Version: {VERSION}\n"
216
+ "Author: Eagle'sBaby,EAShine\n"
217
+ "Bilibili: 我阅读理解一直可以的\n"
218
+ "Bilibili UID: 129249826")
219
+ # f"Gitee URL: <a href='{GITEE_URL}'>{GITEE_URL}</a>")
220
+ self.url_label.setText(f"Gitee URL: <a href='{GITEE_URL}'>{GITEE_URL}</a>")
221
+ self.url_label.setOpenExternalLinks(True) # 允许打开外部链接
222
+
223
+ def open_url(self, url):
224
+ print(url)
225
+ QDesktopServices.openUrl(QUrl(url))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyipcore
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: (PyQt5 based) Create "Ipcore" from verilog(Need iverilog). Provide "Param Value" and "Port Control" function. This kind of IpCore is not safe, only for convenience
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Operating System :: Microsoft :: Windows
12
12
  Requires-Python: >=3
13
13
  Requires-Dist: PyQt5
14
+ Requires-Dist: QScintilla
14
15
  Requires-Dist: reft==0.1.0
15
16
  Requires-Dist: pyverilog==1.3.0
16
17
  Requires-Dist: rbpop==0.1.2
@@ -1,4 +1,5 @@
1
1
  PyQt5
2
+ QScintilla
2
3
  reft==0.1.0
3
4
  pyverilog==1.3.0
4
5
  rbpop==0.1.2
@@ -13,7 +13,7 @@ from setuptools.command.install import install
13
13
 
14
14
  setup(
15
15
  name='pyipcore',
16
- version='0.4.8',
16
+ version='0.4.9',
17
17
  description='(PyQt5 based) Create "Ipcore" from verilog(Need iverilog). Provide "Param Value" and "Port Control" function. This kind of IpCore is not safe, only for convenience',
18
18
  # long_description=long_description,
19
19
  author_email='2229066748@qq.com',
@@ -30,6 +30,7 @@ setup(
30
30
  python_requires='>=3',
31
31
  install_requires=[
32
32
  "PyQt5",
33
+ "QScintilla",
33
34
  "reft==0.1.0",
34
35
  "pyverilog==1.3.0",
35
36
  "rbpop==0.1.2",
@@ -1,71 +0,0 @@
1
- from rbpop import WinManager, RbpopInfo, RbpopWarn, RbpopError
2
- from threading import Thread
3
- import winsound
4
- import time
5
- import re
6
-
7
-
8
- class BeepThread(Thread):
9
- def __init__(self):
10
- # 主程序退出后,子线程也退出
11
- super().__init__(daemon=True)
12
- self.tasks = []
13
- self.flag = True
14
-
15
- def Beep(self, freq, duration):
16
- self.tasks.append((freq, duration))
17
-
18
- def run(self):
19
- while self.flag:
20
- if not self.tasks:
21
- time.sleep(0.2)
22
- continue
23
- freq, duration = self.tasks.pop(0)
24
- winsound.Beep(freq, duration)
25
-
26
- def stop(self):
27
- self.flag = False
28
-
29
-
30
- class BeepWinManager(WinManager):
31
- def __init__(self):
32
- super().__init__()
33
- self.beep = BeepThread()
34
- self.beep.start()
35
-
36
- def add(self, win, freq, duration):
37
- super().add(win)
38
- self.beep.Beep(freq, duration)
39
-
40
-
41
- _GLOBAL_WM = [None]
42
-
43
- def QPop(pop_win_inst, freq=400, duration=100):
44
- if _GLOBAL_WM[0] is None:
45
- _GLOBAL_WM[0] = BeepWinManager()
46
-
47
- _GLOBAL_WM[0].add(pop_win_inst, freq, duration)
48
-
49
-
50
- def _pop_pre(title, msg):
51
- msg = re.sub(r'(.{30})', r'\1\n', ' ' + msg)
52
- _len = len(msg)
53
- ct = 4000 + _len * 50
54
- return title, msg, ct
55
-
56
-
57
- def PopInfo(title, msg):
58
- title, msg, ct = _pop_pre(title, msg)
59
- QPop(RbpopInfo(msg, title, ct=ct, title_style='color:rgb(105,109,105);font-size:20px;', msg_style='color:rgb(65,98,65);font-size:20px;', close=True), 400, 300)
60
-
61
-
62
- def PopWarn(title, msg):
63
- title, msg, ct = _pop_pre(title, msg)
64
- QPop(RbpopWarn(msg, title, ct=ct, title_style='color:rgb(105,125,85);font-size:20px;', msg_style='color:rgb(85,105,75);font-size:20px;', close=True), 600, 300)
65
-
66
-
67
- def PopError(title, msg):
68
- title, msg, ct = _pop_pre(title, msg)
69
- QPop(RbpopError(msg, title, ct=ct, title_style='color:rgb(225,50,50);font-size:20px;', msg_style='color:rgb(185,50,50);font-size:20px;', close=True), 800, 300)
70
-
71
-
File without changes
File without changes
File without changes
File without changes
File without changes