小编Kev*_*ALA的帖子

如何通过在 QtableWidget 中按删除键来删除行?

我想删除 Qtablewidget 的一行而不添加按钮,只需按键盘上的删除键即可。我知道,我需要使用按键事件,但不确定如何将事件分配给特定的表格小部件,并且在 GUI 中具有其他选项卡的其他部分中不会激活按键事件(长话短说:按键事件只是专用于特定的表)。

按钮删除样式:

for i in rows:
                self.tableWidget.removeRow(i)
Run Code Online (Sandbox Code Playgroud)

尝试关键事件:

QtCore.Qt.Key_Delete
QtGui.QTableWidget.keyPressEvent(...,...)
Run Code Online (Sandbox Code Playgroud)

python pyqt pyqt5

2
推荐指数
1
解决办法
3370
查看次数

How to glue (stitch) two python code together?

I am wondering what is the best way to put together codes from different python files into a new python file. Lets say the first file 1.pywould consist of:

def(...):
    a=1
    b=2
    return c=a+b
Run Code Online (Sandbox Code Playgroud)

And another file 2.py consists of:

def(...):
    d = 4
    e = c*d
    return e
Run Code Online (Sandbox Code Playgroud)

Now let's say you have a final file, final.py, which you want all the codes from 1.py and 2.py copied word by word to it in a specific order …

python python-3.x

0
推荐指数
1
解决办法
78
查看次数

标签 统计

python ×2

pyqt ×1

pyqt5 ×1

python-3.x ×1