We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
没用过PR就不直接提交了 先放效果 应该还算符合fluent design 下面使用了EditableComboBox,可以手动传参,决定是否允许自行填写 实现代码
class InputDialog(MaskDialogBase, Ui_Input_dialog): def __init__(self): pass def run(self, parent, title: str, content: str, options: list[str] = [], editable: bool = True) -> str: ''' Receive an optional argv `options` which will be shown in the `ComboBox`\n Return input txt ''' super().__init__(parent) self.setupUi(self.widget) self.widget.setFixedSize(360, 220) FluentStyleSheet.DIALOG.apply(self) self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True) self.btn_cancel.setShortcut('Alt+N') self.btn_ok.setShortcut('Alt+Y') self.btn_cancel.clicked.connect(self.cancel) self.btn_ok.clicked.connect(self.ok) self.title.setText(title) self.content.setText(content) # 这是一个自用的工具集, 在最下面贴出了最小代码 sltk.unique_add_items(self.comboBox, options, format_item=False) self.comboBox.setReadOnly(not editable) # self.show() self.exec() return self.comboBox.currentText() if self.status else None def cancel(self): self.status = False self.close() def ok(self): self.status = True self.close() class sltk(): def unique_add_items(widget: QComboBox | ComboBox | QListWidget | ListWidget, *items: str | list[str], format_item: bool = True): '''为ComboBox不重复地添加一个或多个item,同时格式化路径(如果可以)''' previous_items = [(widget.itemText(i) if type(widget) in [ QComboBox, ComboBox]else widget.item(i).text()) for i in range(widget.count())] if type(items[0]) == list: items = items[0] for i in items: if format_item: i = os.path.realpath(i) if i not in previous_items: widget.addItem(i)
ui文件 input_dialog.zip
The text was updated successfully, but these errors were encountered:
感觉这个还是用 MessageBox Base 让用户自己来实现比较好,WinUI 组件库中也只提供 ContentDialog
ContentDialog
Sorry, something went wrong.
No branches or pull requests
没用过PR就不直接提交了
先放效果
应该还算符合fluent design
下面使用了EditableComboBox,可以手动传参,决定是否允许自行填写
实现代码
ui文件
input_dialog.zip
The text was updated successfully, but these errors were encountered: