我需要实现LineEdit小部件,可以在文本区域的右端添加工具按钮.我知道有两种方法可以做到这一点但两种解决方案看起来都很丑
1)添加工具按钮作为QLineEdit的子窗口小部件,并处理resizeEvent以正确定位它们.主要缺点是如果文本足够长,它可能出现在工具按钮下.
2)另一个解决方案是将行编辑和按钮放在框架内并覆盖样式以隐藏线条框架并使QFrame看起来像QLineEdit.
我需要一种最好的方法来实现这样的小部件.我的小部件也应该是风格意识.
我需要测试我的类的构造函数调用一些方法
class ProductionClass:
def __init__(self):
self.something(1, 2, 3)
def method(self):
self.something(1, 2, 3)
def something(self, a, b, c):
pass
Run Code Online (Sandbox Code Playgroud)
这个课程来自'unittest.mock - 入门'.正如在那里写的,我可以确保'方法'被称为'某事'如下.
real = ProductionClass()
real.something = MagicMock()
real.method()
real.something.assert_called_once_with(1, 2, 3)
Run Code Online (Sandbox Code Playgroud)
但是如何为构造函数测试相同的呢?
据我所知,在postgresql中删除主键的唯一方法是
ALTER TABLE schema.tableName DROP CONSTRAINT constraint_name;
默认情况下,约束名称是tableName_pkey,但是有时如果表已经重命名,我就无法获得原始表名来构造右约束名.
例如,表创建为A然后重命名为B约束仍为A_pkey但我只有B.
您是否知道通过只知道模式名称和表名来删除pkey约束的正确方法?
我正在编写programm来执行此操作,因此我只需要使用SQL查询.像"打开pgAdmin并查看约束名称"这样的解决方案将无效.
我需要在它的正文中获取tcl proc的调用行号.
从8.5 tcl开始有info frame命令允许以下内容:
proc printLine {} {
set lineNum [dict get [info frame 1] line]
}
Run Code Online (Sandbox Code Playgroud)
我需要相同的8.4