AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-19198552

Matthias Schweikart's questions

Martin Hope
Matthias Schweikart
Asked: 2024-10-06 18:05:32 +0800 CST

当 PanedWindow 忘记小部件时防止窗口调整大小

  • 5

当我在调整根窗口大小之前“忘记”或“添加”窗口小部件到 PanedWindow 窗口小部件时,此操作会更改根窗口大小。但是,在使用鼠标指针调整根窗口大小后,“忘记”或“添加”不会再更改窗口大小,只有 PanedWindow 的“子窗口”会更改其大小。

在任何根窗口调整大小之前,如何才能在这些操作期间保持根窗口大小稳定?

这是我的示例代码:

import tkinter as tk
from tkinter import ttk

state = "shown"
def hide_show(paned, canvas):
    global state
    if state=="shown":
        paned.forget(canvas)
        state = "hidden"
    else:
        paned_window.add(canvas, weight= 1)
        state = "shown"

root = tk.Tk()
paned_window = ttk.PanedWindow(root, orient=tk.HORIZONTAL,)
button       = ttk.Button     (root, text="hide/show", command=lambda: hide_show(paned_window, canvas2))
paned_window.grid(row=0, sticky=(tk.W, tk.E, tk.S, tk.N))
button.grid      (row=1, sticky=tk.W)
root.rowconfigure   (0, weight=1)
root.rowconfigure   (1, weight=0)
root.columnconfigure(0, weight=1)

canvas1 = tk.Canvas(paned_window, height=100, width=100, bg="red")
canvas1.grid()
paned_window.add(canvas1, weight= 1)
canvas2 = tk.Canvas(paned_window, height=100, width=100, bg="green")
canvas2.grid()
paned_window.add(canvas2, weight= 1)

root.mainloop()
python
  • 1 个回答
  • 26 Views
Martin Hope
Matthias Schweikart
Asked: 2024-04-17 19:43:33 +0800 CST

嵌入式配置可以用于生成中的实例吗?

  • 6

在 VHDL 体系结构声明区域中,我有时会使用嵌入式配置,例如for and_gate_inst : and_gate use entity work.and_gate(rtl);但当实例位于生成内部时,我不知道如何编写此嵌入式配置。也许这不受支持。我的代码示例中的嵌入式配置语句产生错误并且不正确:

library ieee;
use ieee.std_logic_1164.all;
entity and_gate is
    port (
        inp1_i, inp2_i : in std_logic;
        out_o  : out std_logic
    );
end entity;
architecture rtl of and_gate is
begin
    out_o <= inp1_i and inp2_i;
end architecture;

library ieee;
use ieee.std_logic_1164.all;
entity embedded_conf is
end entity embedded_conf;
library work;
architecture struct of embedded_conf is
    signal inp1, inp2, out1  : std_logic;
    component and_gate is
        port (
            inp1_i : in  std_logic;
            inp2_i : in  std_logic;
            out_o  : out std_logic
        );
    end component;
    for dummy_g for and_gate_inst : and_gate use entity work.and_gate(rtl); -- Not correct!!!
begin
    dummy_g: if true generate
        and_gate_inst : and_gate
            port map (
                inp1_i => inp1,
                inp2_i => inp2,
                out_o  => out1
            );
    end generate dummy_g;
end architecture;

有谁知道这个嵌入式配置必须是什么样子?

vhdl
  • 1 个回答
  • 33 Views
Martin Hope
Matthias Schweikart
Asked: 2024-03-07 02:03:45 +0800 CST

如何在 tkinter 窗口最小化时切换其标题?

  • 5

我有一个 tkinter 应用程序,它的窗口标题中包含加载到应用程序中的文件的完整路径名。由于路径名通常很长,因此只能在窗口未最小化时显示。当它最小化(为图标)时,只有路径名的开头可见。所以我现在想将标题切换为仅文件名,窗口最小化。我在这里找到了一个解决方案并根据我的问题进行了调整:

import tkinter as tk

title_saved = ""
def __made_to_window(event):
    print("__made_to_window")
    global title_saved
    if title_saved!="":
        root.title(title_saved)
        title_saved = ""

def __made_to_icon(event):
    print("__made_to_icon")
    global title_saved
    if title_saved=="":
        title_saved = root.title()
    root.title("filename.py")

root = tk.Tk()
root.title("C/folder1/folder2/folder3/folder4/folder5/filename.py")

canvas = tk.Canvas(root, height=100, width=400)
canvas.grid()
root.bind("<Unmap>", __made_to_icon)
root.bind("<Map>"  , __made_to_window)
root.mainloop()

正如您在我的示例代码中看到的,该解决方案有效。但我不喜欢它,因为当窗口最小化时,使用的绑定不仅被激活一次,而且被激活两次(在我的大应用程序中,当窗口最小化时,它被激活 10 次)。因此,必须检查变量 title_saved 是否已不再为空。

所以我正在寻找一种更优雅的解决方案,特别是因为我相信在最小化时更改标题一定是一个常见问题。

你有什么想法?

python
  • 1 个回答
  • 22 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve