
设计tkinter控制按钮实时生成函数图像出现问题
在代码中,模拟开关的行为时,出现了以下问题:
修改后的代码片段:
def toggle_manual_switch(self):
# 获取当前时刻的索引
current_index = int(self.current_time_index) # FIXME: Q1.这个值没有更新过
# ... 省略其他代码 ...
def update_plot(self, frame):
# 更新 current_time_index
self.current_time_index = frame
# ... 省略其他代码 ...
def calculate_circuit_response(self, current_time_index):
# ... 省略其他代码 ...
if not self.previous_switch_state:
# 开关断开
self.VoltageOverTime[current_time_index:] = 0 # FIXME: VoltageOverTime 和 CurrentOverTime 的赋值有些问题,之前是只赋值一个点?
self.CurrentOverTime[current_time_index:] = 0
else:
# 开关闭合
self.VoltageOverTime[current_time_index:] = V_battery * np.ones_like(
self.VoltageOverTime[current_time_index:]
)
self.CurrentOverTime[current_time_index:] = V_battery / R_load * np.ones_like(
self.CurrentOverTime[current_time_index:]
)以上就是Tkinter实时绘图按钮控制:如何解决开关按钮无法精确控制函数图像绘制起始时间和电路状态?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号