开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 1 Fork 1

iounce/Python-Cpp-demo

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
main_window.py 23.87 KB
一键复制 编辑 原始数据 按行查看 历史
iounce 提交于 2023年09月02日 17:17 +08:00 . internationalize title/text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
# -*- coding: utf-8 -*-
from PySide6.QtGui import QCursor, QAction
from PySide6.QtCore import Qt, QSize, QRect, QEvent
from PySide6.QtWidgets import QApplication, QMainWindow, \
QDialog, QMenu,QLabel, QLineEdit, QWidget, QPushButton, \
QTableWidget, QTableWidgetItem, QAbstractItemView, QHeaderView, \
QGridLayout, QHBoxLayout, QSpacerItem, QSizePolicy
from ui_main import Ui_MainWindow
from theme_window import ThemeWindow
from feedback_window import FeedbackWindow
from about_window import AboutWindow
from message_window import MessageWindow
from cursor import CursorDirection
from language import Language
from icon import LogoIcon, MenuIcon
from style import LabelStyle, ButtonStyle, WidgetStyle, MenuStyle
from utils import FileUtils, WidthHelper
from cpp import CppFileHelper
from widget import WidgetManager
# main window
class MainWindow(QMainWindow):
def __init__(self, p_theme, p_translator, p_setting):
super(MainWindow, self).__init__()
self.theme = p_theme
self.translator = p_translator
self.setting = p_setting
self.cursor_direction = CursorDirection.Default
self.left_btn_pressed = False
self.drag_point = 0
self.cn_menu = None
self.en_menu = None
self.wid_mng = WidgetManager()
self.func_define_list = []
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.init()
# initialize the window
def init(self):
self.init_window()
self.init_app_bar()
self.init_more_menu()
self.init_language()
self.init_layout()
self.init_class()
self.init_func()
self.init_result()
self.init_tab_order()
# initialize the window style
def init_window(self):
self.ui.wid_main.setStyleSheet(WidgetStyle.get_border('wid_main'))
self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint \
| Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint \
| Qt.WindowMaximizeButtonHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setMouseTracking(True)
# initialize the window title bar(self-defined logo, title and min/restore/max icons)
def init_app_bar(self):
self.ui.lbl_logo.setMinimumSize(QSize(24, 24))
self.ui.lbl_logo.setMaximumSize(QSize(24, 24))
self.ui.lbl_logo.setPixmap(LogoIcon.get_pixmap())
self.ui.lbl_logo.setScaledContents(True)
self.ui.btn_max.setVisible(True)
self.ui.btn_restore.setVisible(False)
self.ui.btn_more.setFlat(True)
self.ui.btn_min.setFlat(True)
self.ui.btn_close.setFlat(True)
self.ui.btn_max.setFlat(True)
self.ui.btn_restore.setFlat(True)
self.ui.btn_more.setIcon(MenuIcon.get_more())
self.ui.btn_min.setIcon(MenuIcon.get_min())
self.ui.btn_close.setIcon(MenuIcon.get_close())
self.ui.btn_max.setIcon(MenuIcon.get_max())
self.ui.btn_restore.setIcon(MenuIcon.get_restore())
self.ui.btn_more.setIconSize(QSize(24, 24))
self.ui.btn_min.setIconSize(QSize(24, 24))
self.ui.btn_close.setIconSize(QSize(24, 24))
self.ui.btn_max.setIconSize(QSize(24, 24))
self.ui.btn_restore.setIconSize(QSize(24, 24))
self.ui.btn_close.setStyleSheet(ButtonStyle.get_close())
self.ui.btn_min.clicked.connect(self.on_min)
self.ui.btn_close.clicked.connect(self.on_exit)
self.ui.btn_max.clicked.connect(self.on_max)
self.ui.btn_restore.clicked.connect(self.on_restore)
self.ui.lbl_title.setStyleSheet(LabelStyle.get_title())
# initialize the other menu(theme, language, feedback and about)
def init_more_menu(self):
menu = QMenu(self)
menu.setStyleSheet(MenuStyle.get_more())
action = QAction(MainWindow.tr('menu_theme'), self)
action.setIcon(MenuIcon.get_theme())
action.triggered.connect(self.on_show_theme)
menu.addAction(action)
self.wid_mng.add(action, text='menu_theme')
languageMenu = QMenu(MainWindow.tr('menu_language'))
languageMenu.setIcon(MenuIcon.get_language())
menu.addMenu(languageMenu)
self.wid_mng.add(languageMenu, text='menu_language')
action = QAction(MainWindow.tr('menu_chinese'), languageMenu)
action.setCheckable(True)
action.setChecked(True)
action.triggered.connect(self.on_show_chinese)
languageMenu.addAction(action)
self.cn_menu = action
self.wid_mng.add(action, text='menu_chinese')
action = QAction(MainWindow.tr('menu_english'), languageMenu)
action.setCheckable(True)
action.setChecked(False)
action.triggered.connect(self.on_show_english)
languageMenu.addAction(action)
self.en_menu = action
self.wid_mng.add(action, text='menu_english')
action = QAction(MainWindow.tr('menu_feedback'), self)
action.setIcon(MenuIcon.get_feedback())
action.triggered.connect(self.on_show_feedback)
menu.addAction(action)
self.wid_mng.add(action, text='menu_feedback')
action = QAction(MainWindow.tr('menu_about'), self)
action.setIcon(MenuIcon.get_about())
action.triggered.connect(self.on_show_about)
menu.addAction(action)
self.wid_mng.add(action, text='menu_about')
self.ui.btn_more.setMenu(menu)
self.ui.btn_more.setStyleSheet(ButtonStyle.get_more())
# initialize the default language
def init_language(self):
if self.setting.get_language() == Language.Chinese.value:
self.cn_menu.setChecked(True)
self.en_menu.setChecked(False)
else:
self.en_menu.setChecked(True)
self.cn_menu.setChecked(False)
def init_layout(self):
self.layout_main = QGridLayout(self.ui.widget_body)
self.layout_main.setContentsMargins(0, 0, 0, 0)
self.layout_class = QHBoxLayout()
self.layout_func = QHBoxLayout()
self.layout_result = QHBoxLayout()
self.layout_main.addLayout(self.layout_class, 0, 0, 1, 2)
self.layout_main.addLayout(self.layout_func, 1, 0, 1, 2)
self.layout_main.addLayout(self.layout_result, 2, 0, 1, 2)
self.layout_class_left = QHBoxLayout()
self.layout_class_right = QHBoxLayout()
self.layout_class.addLayout(self.layout_class_left)
self.layout_class.addLayout(self.layout_class_right)
self.layout_func_left = QHBoxLayout()
self.layout_func_right = QHBoxLayout()
self.layout_func.addLayout(self.layout_func_left)
self.layout_func.addLayout(self.layout_func_right)
def init_class(self):
widget = QWidget(self)
widget.setMinimumWidth(16)
widget.setMaximumWidth(16)
self.layout_class_left.addWidget(widget)
label_class_name = QLabel()
label_class_name.setText(WidthHelper.format_text(MainWindow.tr('label_class_name')))
label_class_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
label_class_name.setMaximumWidth(64)
self.wid_mng.add(label_class_name, text='label_class_name')
self.layout_class_left.addWidget(label_class_name)
self.edit_class_name = QLineEdit()
self.edit_class_name.setMaximumWidth(128)
self.edit_class_name.setMinimumHeight(32)
self.edit_class_name.installEventFilter(self)
self.layout_class_left.addWidget(self.edit_class_name)
label_file_name = QLabel()
label_file_name.setText(WidthHelper.format_text(MainWindow.tr('label_file_name')))
label_file_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
label_file_name.setMaximumWidth(64)
self.wid_mng.add(label_file_name, text='label_class_name')
self.layout_class_left.addWidget(label_file_name)
self.edit_file_name = QLineEdit()
self.edit_file_name.setMaximumWidth(128)
self.edit_file_name.setMinimumHeight(32)
self.edit_file_name.setReadOnly(True)
self.layout_class_left.addWidget(self.edit_file_name)
spacer = QSpacerItem(
32, 32, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.layout_class_left.addItem(spacer)
self.btn_add_func = QPushButton()
self.btn_add_func.setText(WidthHelper.format_text(MainWindow.tr('btn_add_func')))
self.btn_add_func.setMaximumWidth(96)
self.btn_add_func.setMinimumHeight(32)
self.btn_add_func.clicked.connect(self.on_add_func)
self.wid_mng.add(self.btn_add_func, text='btn_add_func')
self.layout_class_right.addWidget(self.btn_add_func)
self.btn_sub_func = QPushButton()
self.btn_sub_func.setText(WidthHelper.format_text(MainWindow.tr('btn_del_func')))
self.btn_sub_func.setMaximumWidth(96)
self.btn_sub_func.setMinimumHeight(32)
self.btn_sub_func.clicked.connect(self.on_sub_func)
self.wid_mng.add(self.btn_sub_func, text='btn_add_func')
self.layout_class_right.addWidget(self.btn_sub_func)
self.btn_gen_cpp = QPushButton()
self.btn_gen_cpp.setText(WidthHelper.format_text(MainWindow.tr('btn_gen_file')))
self.btn_gen_cpp.setMaximumWidth(96)
self.btn_gen_cpp.setMinimumHeight(32)
self.btn_gen_cpp.clicked.connect(self.on_gen_cpp)
self.wid_mng.add(self.btn_gen_cpp, text='btn_add_func')
self.layout_class_right.addWidget(self.btn_gen_cpp)
widget = QWidget(self)
widget.setMinimumWidth(16)
widget.setMaximumWidth(16)
self.layout_class_right.addWidget(widget)
def init_func(self):
widget = QWidget(self)
widget.setMinimumWidth(16)
widget.setMaximumWidth(16)
self.layout_func_left.addWidget(widget)
label_return_name = QLabel()
label_return_name.setText(WidthHelper.format_text(MainWindow.tr('label_return_value')))
label_return_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
label_return_name.setMaximumWidth(64)
self.wid_mng.add(label_return_name, text='label_return_value')
self.layout_func_left.addWidget(label_return_name)
self.edit_return_name = QLineEdit()
self.edit_return_name.setMaximumWidth(128)
self.edit_return_name.setMinimumHeight(32)
self.edit_return_name.setMinimumHeight(32)
self.layout_func_left.addWidget(self.edit_return_name)
label_func_name = QLabel()
label_func_name.setText(WidthHelper.format_text(MainWindow.tr('label_func_name')))
label_func_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
label_func_name.setMaximumWidth(64)
self.wid_mng.add(label_func_name, text='label_func_name')
self.layout_func_left.addWidget(label_func_name)
self.edit_func_name = QLineEdit()
self.edit_func_name.setMaximumWidth(128)
self.edit_func_name.setMinimumHeight(32)
self.layout_func_left.addWidget(self.edit_func_name)
label_param_name = QLabel()
label_param_name.setText(WidthHelper.format_text(MainWindow.tr('label_input_param')))
label_param_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
label_param_name.setMaximumWidth(64)
self.wid_mng.add(label_param_name, text='label_input_param')
self.layout_func_left.addWidget(label_param_name)
self.edit_param_name = QLineEdit()
self.edit_param_name.setMinimumHeight(32)
self.edit_param_name.setMinimumHeight(32)
self.layout_func_left.addWidget(self.edit_param_name)
widget = QWidget(self)
widget.setMinimumWidth(16)
widget.setMaximumWidth(16)
self.layout_func_right.addWidget(widget)
def init_result(self):
widget = QWidget(self)
widget.setMinimumWidth(10)
widget.setMaximumWidth(10)
self.layout_result.addWidget(widget)
self.init_result_table()
widget = QWidget(self)
widget.setMinimumWidth(16)
widget.setMaximumWidth(16)
self.layout_result.addWidget(widget)
def init_result_table(self):
table_col_names = [MainWindow.tr('column_return_value'), MainWindow.tr('column_func_name'), '(', MainWindow.tr('column_input_param'), ')', ';']
self.table_result = QTableWidget(self.ui.widget_body)
self.layout_result.addWidget(self.table_result)
self.table_result.setSelectionMode(QAbstractItemView.SingleSelection)
self.table_result.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table_result.setColumnCount(len(table_col_names))
self.table_result.setHorizontalHeaderLabels(table_col_names)
self.table_result.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.table_result.horizontalHeader().setSectionResizeMode(3,
QHeaderView.Interactive)
#self.table_result.setColumnWidth(3, 300)
def add_result_table(self, func_list):
row = self.table_result.rowCount()
self.table_result.setRowCount(row + 1)
column = 0
for item in func_list:
item = QTableWidgetItem(item)
item.setFlags(item.flags and (~Qt.ItemFlag.ItemIsEditable))
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.table_result.setItem(row, column, item)
column += 1
def init_tab_order(self):
self.setTabOrder(self.edit_class_name, self.edit_return_name)
self.setTabOrder(self.edit_return_name, self.edit_func_name)
self.setTabOrder(self.edit_func_name, self.edit_param_name)
# minimize the window
def on_min(self):
self.showMinimized()
# maximize the window
def on_max(self):
self.ui.btn_max.setVisible(False)
self.ui.btn_restore.setVisible(True)
self.showMaximized()
# restore the window
def on_restore(self):
self.ui.btn_max.setVisible(True)
self.ui.btn_restore.setVisible(False)
self.showNormal()
# exit the application
def on_exit(self):
# confirm before exit
dlg = MessageWindow(self, self.theme, MainWindow.tr('title_exit'), MainWindow.tr('tip_exit_message'))
result = dlg.exec()
if result != QDialog.DialogCode.Accepted:
return
one = QApplication.instance()
one.quit()
def update_table_title(self):
table_col_names = [MainWindow.tr('column_return_value'), MainWindow.tr('column_func_name'), '(', MainWindow.tr('column_input_param'), ')', ';']
self.table_result.setHorizontalHeaderLabels(table_col_names)
# update widgets that created dynamically
# call this function when changing language
def update_dynamic_widgets(self):
self.update_table_title()
dynamic_widgets = self.wid_mng.get_all()
for (widget, text) in dynamic_widgets.items():
if isinstance(widget, QMenu):
widget.setTitle(MainWindow.tr(text))
else:
widget.setText(MainWindow.tr(text))
# show theme window
def on_show_theme(self):
dlg = ThemeWindow(self, self.theme)
dlg.theme_signal.connect(self.proc_theme_signal)
dlg.show()
# response when changing Chinese language
def on_show_chinese(self):
cn_checked = self.cn_menu.isChecked()
en_checked = not cn_checked
self.cn_menu.setChecked(cn_checked)
self.en_menu.setChecked(en_checked)
if cn_checked:
self.translator.load('zh_CN')
self.setting.save(Language.Chinese.value, self.theme.get_theme_name())
else:
self.translator.load('en_US')
self.setting.save(Language.English.value, self.theme.get_theme_name())
self.ui.retranslateUi(self)
self.update_dynamic_widgets()
# response when changing English language
def on_show_english(self):
en_checked = self.en_menu.isChecked()
cn_checked = not en_checked
self.en_menu.setChecked(en_checked)
self.cn_menu.setChecked(cn_checked)
if en_checked:
self.translator.load('en_US')
self.setting.save(Language.English.value, self.theme.get_theme_name())
else:
self.translator.load('zh_CN')
self.setting.save(Language.Chinese.value, self.theme.get_theme_name())
self.ui.retranslateUi(self)
# update the widgets that created dynamically when changing language
self.update_dynamic_widgets()
# show feedback window
def on_show_feedback(self):
dlg = FeedbackWindow(self, self.theme)
dlg.show()
# show about window
def on_show_about(self):
dlg = AboutWindow(self, self.theme)
dlg.show()
def eventFilter(self, watched, event):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key.Key_Tab:
if watched == self.edit_class_name:
class_name = self.edit_class_name.text()
self.edit_file_name.setText(class_name + ".cpp")
return super().eventFilter(watched, event)
def on_add_func(self):
func_list = []
func_return_type = self.edit_return_name.text().strip()
func_name = self.edit_func_name.text().strip()
func_param_name = self.edit_param_name.text().strip()
func_list.append(func_return_type)
func_list.append(func_name)
func_list.append('(')
func_list.append(func_param_name)
func_list.append(')')
func_list.append(';')
self.add_result_table(func_list)
func_param = {}
func_param["func_access_type"] = "public"
func_param["show_access_type"] = "1" if len(
self.func_define_list) == 0 else ""
func_param["func_name"] = func_name
func_param["func_return_type"] = func_return_type
func_param["func_param_name"] = func_param_name
func_param["func_param_type"] = ""
self.func_define_list.append(func_param)
self.reset_param()
print('on_add_func: ', func_list)
def on_sub_func(self):
row = self.table_result.rowCount()
self.table_result.setRowCount(row - 1)
self.func_define_list.pop()
print('on_sub_func')
def on_gen_cpp(self):
print(self.func_define_list)
class_name = self.edit_class_name.text()
CppFileHelper.gen_h_cpp(class_name, self.func_define_list)
print('on_gen_cpp')
def reset_param(self):
self.edit_return_name.clear()
self.edit_func_name.clear()
self.edit_param_name.clear()
# process the signal of changing theme
def proc_theme_signal(self, content):
language = Language.Chinese if self.cn_menu and self.cn_menu.isChecked() else Language.English
self.setting.save(language.value, FileUtils.get_name(content))
# get the cursor direction when dragging the mouse
def get_cursor_direction(self, global_point):
padding = 1
rect = self.rect()
top_left = self.mapToGlobal(rect.topLeft())
bottom_right = self.mapToGlobal(rect.bottomRight())
x = global_point.x()
y = global_point.y()
if top_left.x() + padding >= x >= top_left.x() and top_left.y() + padding >= y >= top_left.y():
self.cursor_direction = CursorDirection.LeftTop
self.setCursor(QCursor(Qt.SizeFDiagCursor))
elif bottom_right.x() - padding <= x <= bottom_right.x() and bottom_right.y() - padding <= y <= bottom_right.y():
self.cursor_direction = CursorDirection.RightBottom
self.setCursor(QCursor(Qt.SizeFDiagCursor))
elif top_left.x() + padding >= x >= top_left.x() and bottom_right.y() - padding <= y <= bottom_right.y():
self.cursor_direction = CursorDirection.LeftBottom
self.setCursor(QCursor(Qt.SizeBDiagCursor))
elif bottom_right.x() >= x >= bottom_right.x() - padding and top_left.y() <= y <= top_left.y() + padding:
self.cursor_direction = CursorDirection.RightTop
self.setCursor(QCursor(Qt.SizeBDiagCursor))
elif top_left.x() + padding >= x >= top_left.x():
self.cursor_direction = CursorDirection.Left
self.setCursor(QCursor(Qt.SizeHorCursor))
elif bottom_right.x() >= x >= bottom_right.x() - padding:
self.cursor_direction = CursorDirection.Right
self.setCursor(QCursor(Qt.SizeHorCursor))
elif top_left.y() <= y <= top_left.y() + padding:
self.cursor_direction = CursorDirection.Up
self.setCursor(QCursor(Qt.SizeVerCursor))
elif bottom_right.y() >= y >= bottom_right.y() - padding:
self.cursor_direction = CursorDirection.Down
self.setCursor(QCursor(Qt.SizeVerCursor))
else:
self.cursor_direction = CursorDirection.Default
self.setCursor(QCursor(Qt.ArrowCursor))
# process mouse event when dragging the window
def mousePressEvent(self, e):
if e.button() == Qt.LeftButton:
self.left_btn_pressed = True
if self.cursor_direction != CursorDirection.Default:
self.mouseGrabber()
else:
self.drag_point = e.globalPos() - self.frameGeometry().topLeft()
def mouseMoveEvent(self, e):
global_point = e.globalPos()
rect = self.rect()
top_left = self.mapToGlobal(rect.topLeft())
bottom_right = self.mapToGlobal(rect.bottomRight())
if not self.left_btn_pressed:
self.get_cursor_direction(global_point)
else:
if self.cursor_direction != CursorDirection.Default:
move_rect = QRect(top_left, bottom_right)
if self.cursor_direction == CursorDirection.Left:
if bottom_right.x() - global_point.x() <= self.minimumWidth():
move_rect.setX(top_left.x())
else:
move_rect.setX(global_point.x())
elif self.cursor_direction == CursorDirection.Right:
move_rect.setWidth(global_point.x() - top_left.x())
elif self.cursor_direction == CursorDirection.Up:
if bottom_right.y() - global_point.y() <= self.minimumHeight():
move_rect.setY(top_left.y())
else:
move_rect.setY(global_point.y())
elif self.cursor_direction == CursorDirection.Down:
move_rect.setHeight(global_point.y() - top_left.y())
elif self.cursor_direction == CursorDirection.LeftTop:
if bottom_right.x() - global_point.x() <= self.minimumWidth():
move_rect.setX(top_left.x())
else:
move_rect.setX(global_point.x())
if bottom_right.y() - global_point.y() <= self.minimumHeight():
move_rect.setY(top_left.y())
else:
move_rect.setY(global_point.y())
elif self.cursor_direction == CursorDirection.RightTop:
move_rect.setWidth(global_point.x() - top_left.x())
move_rect.setY(global_point.y())
elif self.cursor_direction == CursorDirection.LeftBottom:
move_rect.setX(global_point.x())
move_rect.setHeight(global_point.y() - top_left.y())
elif self.cursor_direction == CursorDirection.RightBottom:
move_rect.setWidth(global_point.x() - top_left.x())
move_rect.setHeight(global_point.y() - top_left.y())
else:
pass
self.setGeometry(move_rect)
else:
self.move(e.globalPos() - self.drag_point)
e.accept()
def mouseReleaseEvent(self, e):
if e.button() == Qt.LeftButton:
self.left_btn_pressed = False
if self.cursor_direction != CursorDirection.Default:
self.releaseMouse()
self.setCursor(QCursor(Qt.ArrowCursor))
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Python与C++交互示例
暂无标签
MIT
使用 MIT 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/iounce_admin/python-cpp-demo.git
git@gitee.com:iounce_admin/python-cpp-demo.git
iounce_admin
python-cpp-demo
Python-Cpp-demo
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /