gpt4 book ai didi

gtk - 使 GTK 输入框更小

转载 作者:行者123 更新时间:2023-12-01 12:20:21 27 4
gpt4 key购买 nike

我正在尝试使用 Gtk 在 Julia 中制作一个 GUI 程序。我的程序包括大量的 GtkEntry 框。但是,我遇到了空间问题,因为条目框在实际字符周围有很多内部填充。我想至少减少顶部和底部的空白。我曾尝试使用 setproperty!()函数更改 height-request值(value),但这似乎只能使盒子更大,而不是更小。此外,margin , margin-top等字段默认都设置为0。同样,我可以使它们变大但不能变小。

这有可能解决吗?我在下面包含了一个最小的工作示例、一个屏幕截图和一个显示可用属性的 Julia REPL 输出。

编辑:
我也尝试使用带有内容的 css 文件 (test.css)

entry {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}

Julia 0.6.0 代码:
using Gtk

win = GtkWindow("Example")

sb = GtkGrid()
function sb_entry(label)
frame = GtkFrame(label)
entry = GtkEntry()
setproperty!(entry, :input_purpose, 2)
push!(frame, entry)
return frame
end
sb_rows = sb_entry("rows")
sb_cols = sb_entry("cols")
sb_row_off = sb_entry("row off")
sb_col_off = sb_entry("col off")
sb[1,1] = sb_rows
sb[2,1] = sb_cols
sb[1,2] = sb_row_off
sb[2,2] = sb_col_off
setproperty!(sb, :column_homogeneous, true)
setproperty!(sb, :column_spacing, 5)
setproperty!(sb, :row_spacing, 5)

push!(win, sb)

### begin edit (css)

screen = Gtk.GAccessor.screen(win)
provider = GtkCssProviderLeaf(filename="/path/to/test.css")

ccall((:gtk_style_context_add_provider_for_screen, Gtk.libgtk), Void,
(Ptr{Void}, Ptr{GObject}, Cuint),
screen, provider, 1)

### end edit (css)

showall(win)

if !isinteractive()
c = Condition()
signal_connect(win, :destroy) do widget
notify(c)
end
wait(c)
end

Minimal Example
julia> sb_row_off[1]

Gtk.GtkEntryLeaf(editing-canceled=FALSE, name="", parent, width-request=-1,
height-request=-1, visible=TRUE, sensitive=TRUE, app-paintable=FALSE,
can-focus=TRUE, has-focus=FALSE, is-focus=TRUE, focus-on-click=TRUE,
can-default=FALSE, has-default=FALSE, receives-default=FALSE, composite-child=FALSE,
style, events=0, no-show-all=FALSE, has-tooltip=FALSE, tooltip-markup=NULL,
tooltip-text=NULL, window, opacity=1.000000, double-buffered, halign=GTK_ALIGN_FILL,
valign=GTK_ALIGN_FILL, margin-left, margin-right, margin-start=0, margin-end=0,
margin-top=0, margin-bottom=0, margin=0, hexpand=FALSE, vexpand=FALSE,
hexpand-set=FALSE, vexpand-set=FALSE, expand=FALSE, scale-factor=2, buffer,
cursor-position=0, selection-bound=0, editable=TRUE, max-length=0, visibility=TRUE,
has-frame=TRUE, inner-border, invisible-char=9679, activates-default=FALSE,
width-chars=-1, max-width-chars=-1, scroll-offset=0, text="", xalign=0.000000,
truncate-multiline=FALSE, shadow-type, overwrite-mode=FALSE, text-length=0,
invisible-char-set=FALSE, caps-lock-warning=TRUE, progress-fraction=0.000000,
progress-pulse-step=0.100000, primary-icon-pixbuf, secondary-icon-pixbuf,
primary-icon-stock, secondary-icon-stock, primary-icon-name=NULL,
secondary-icon-name=NULL, primary-icon-gicon, secondary-icon-gicon,
primary-icon-storage-type=GTK_IMAGE_EMPTY,
secondary-icon-storage-type=GTK_IMAGE_EMPTY, primary-icon-activatable=TRUE,
secondary-icon-activatable=TRUE, primary-icon-sensitive=TRUE,
secondary-icon-sensitive=TRUE, primary-icon-tooltip-text=NULL,
secondary-icon-tooltip-text=NULL, primary-icon-tooltip-markup=NULL,
secondary-icon-tooltip-markup=NULL, im-module=NULL, placeholder-text=NULL,
completion, input-purpose=GTK_INPUT_PURPOSE_DIGITS, input-hints=GTK_INPUT_HINT_NONE,
attributes, populate-all=FALSE, tabs)

最佳答案

entry { min-height: 0px; }允许它尽可能小。根据需要调整大小。

关于gtk - 使 GTK 输入框更小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44866035/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com