위젯을 삭제하여 Gtk.FlowBox에서 위젯을 제거하려고하지만 회색 상자가 남아 있습니다. 위젯이 제거 된 후 인접한 위젯이 제자리에 놓 이도록 회색 상자를 제거하는 방법에 대한 아이디어. 1- 두 이미지 (pixbuf 행) 및 라벨 2- 오버레이 이미지가 FlowBoxGtk.FlowBox에서 위젯 제거
첨가되는 EventBox를 -3- EventBox를 첨가하는 OverlayImage 첨가되어다음은 위젯 포장 어떻게
나는 다음과 같은 방법을 시도 : 1 파괴 EventBox를 을 2 가져 오기 및 오버레이 이미지의 모든 어린이를 파괴하고 다음 두 경우 오버레이 이미지와 EventBox를
을 파괴, 위젯이 제거되지만 빈 지역 숙박 그 자리에 클릭하면 회색이지만 아무것도하지 않습니다 - 그림을보십시오.
빈 공간을 제거하려면 어떻게해야합니까? 다음 위젯이 자동으로 위젯이 제거 된 장소로 떨어지며 다음 위젯이 그 자리에 등등 떨어지게합니다.
코드 여기 가능하고 "removeSelectedBooksFromLibrary"는 FlowBox
이 중 사용자에 의해 선택된 EventBox를 제거 FlowBox에서 https://github.com/babluboy/bookworm/blob/master/src/bookworm.vala#L589
이것 위젯을 추가하는 코드하는 방법 사전
,369에 FlowBox에서 https://github.com/babluboy/bookworm/blob/master/src/bookworm.vala#L512다음은 위젯과 그 부모를 제거하는 솔루션이 추가 된 작업 예제입니다.
public class FlowBoxIssue : Gtk.Window {
public static int main (string[] args) {
Gtk.init (ref args);
FlowBoxIssue window = new FlowBoxIssue();
window.show_all();
Gtk.main();
return 0;
}
public FlowBoxIssue() {
this.title = "FlowBox Issue";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (800, 600);
Gtk.FlowBox library_flowbox = new Gtk.FlowBox();
Gtk.Box library_mainbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 20);
Gtk.ScrolledWindow library_scroll = new Gtk.ScrolledWindow (null, null);
library_scroll.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
library_scroll.add (library_flowbox);
Gtk.Overlay aOverlayImage1 = new Gtk.Overlay();
Gtk.EventBox aEventBox1 = new Gtk.EventBox();
Gtk.EventBox aEventBox2 = new Gtk.EventBox();
Gtk.EventBox aEventBox3 = new Gtk.EventBox();
try{
Gdk.Pixbuf aBookCover1 = new Gdk.Pixbuf.from_file_at_scale("cover.png", 200, 250, false);
Gtk.Image aCoverImage1 = new Gtk.Image.from_pixbuf(aBookCover1);
aOverlayImage1.add(aCoverImage1);
Gtk.Label overlayTextLabel1 = new Gtk.Label("Label 1");
aOverlayImage1.add_overlay(overlayTextLabel1);
aEventBox1.add(aOverlayImage1);
library_flowbox.add (aEventBox1);
}catch(Error e){
}
Gtk.Overlay aOverlayImage2 = new Gtk.Overlay();
try{
Gdk.Pixbuf aBookCover2 = new Gdk.Pixbuf.from_file_at_scale("cover.png", 200, 250, false);
Gtk.Image aCoverImage2 = new Gtk.Image.from_pixbuf(aBookCover2);
aOverlayImage2.add(aCoverImage2);
Gtk.Label overlayTextLabel2 = new Gtk.Label("Label 2");
aOverlayImage2.add_overlay(overlayTextLabel2);
aEventBox2.add(aOverlayImage2);
library_flowbox.add (aEventBox2);
}catch(Error e){
}
Gtk.Overlay aOverlayImage3 = new Gtk.Overlay();
try{
Gdk.Pixbuf aBookCover3 = new Gdk.Pixbuf.from_file_at_scale("cover.png", 200, 250, false);
Gtk.Image aCoverImage3 = new Gtk.Image.from_pixbuf(aBookCover3);
aOverlayImage3.add(aCoverImage3);
Gtk.Label overlayTextLabel3 = new Gtk.Label("Label 3");
aOverlayImage3.add_overlay(overlayTextLabel3);
aEventBox3.add(aOverlayImage3);
library_flowbox.add (aEventBox3);
}catch(Error e){
}
Gtk.Button delete_button = new Gtk.Button.with_label("Delete Pix");
delete_button.clicked.connect (() => {
//This is the line which resolved the issue - get the parent of the widget and destroy it and then destroy the widget
aEventBox2.get_parent().destroy();
aEventBox2.destroy();
});
library_mainbox.pack_start(library_scroll, true, true, 0);
library_mainbox.pack_end(delete_button, true, false, 0);
this.add(library_mainbox);
}
}
코드를 링크하는 것을 잊었습니다 (질문 [MCVE] (http://stackoverflow.com/help/mcve)). – andlabs
코드 언급을 잊어 버린 것에 사과드립니다.나는 MCVE를 만들고 질문을 업데이트하려고 노력할 것입니다. –