1
我使用R和GTK2開發GUI和創造的東西如照片所示。煉油GUI開發的RGTK2
這裏的腳本:
library(RGtk2)
rm(list=ls())
window.master <- gtkWindow("toplevel",show=FALSE)
window.master$setDefaultSize(1024,768)
window.master$set(title="Window Name")
forms.notebook <- gtkNotebook()
forms.notebook$setTabPos("top")
form1.notebook <- gtkNotebook()
form1.notebook$setTabPos("top")
form1.boxp1.y3 <- gtkVBox(FALSE,3)
form1.framep1y1 <- gtkFrame("AAA")
form1.boxp1y1.2y <- gtkVBox(FALSE,2)
form1.boxp1y1.y1.4x <- gtkHBox(FALSE,4)
form1.boxp1y1.y1.4x$packStart(gtkLabel("BBB"),FALSE,FALSE)
form1.boxp1y1.y1.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y1.4x$packStart(gtkLabel("CCC"),FALSE,FALSE)
form1.boxp1y1.y1.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y2.4x <- gtkHBox(FALSE,4)
form1.boxp1y1.y2.4x$packStart(gtkLabel("DDD"),FALSE,FALSE)
form1.boxp1y1.y2.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y2.4x$packStart(gtkLabel("EEE"),FALSE,FALSE)
form1.boxp1y1.y2.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.2y$add(form1.boxp1y1.y1.4x)
form1.boxp1y1.2y$add(form1.boxp1y1.y2.4x)
form1.framep1y1$add(form1.boxp1y1.2y)
form1.framep1y2 <- gtkFrame("FFF")
form1.boxp1y2.2y <- gtkVBox(FALSE,2)
### 1nd row ###
form1.boxp1y1.y1.6x <- gtkHBox(FALSE,6)
form1.boxp1y1.y1.6x$packStart(gtkLabel("GGG"),FALSE,FALSE)
form1.boxp1y1.y1.6x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y1.6x$packStart(gtkLabel("HHH"),FALSE,FALSE)
form1.boxp1y1.y1.6x$packStart(gtkEntry(),FALSE,FALSE)
form1.boxp1y1.y1.6x$packStart(gtkLabel("III"),FALSE,FALSE)
form1.boxp1y1.y1.6x$packStart(gtkEntry(),FALSE,FALSE)
### 2nd row ###
form1.boxp1y1.y2.4x <- gtkHBox(FALSE,4)
form1.boxp1y1.y2.4x$packStart(gtkLabel("JJJ"),FALSE,FALSE)
form1.boxp1y1.y2.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y2.4x$packStart(gtkLabel("KKK"),FALSE,FALSE)
form1.boxp1y1.y2.4x$packStart(gtkEntry(),TRUE,TRUE)
### 3nd row ###
form1.boxp1y1.y3.4x <- gtkHBox(FALSE,4)
form1.boxp1y1.y3.4x$packStart(gtkLabel("LLL"),FALSE,FALSE)
form1.boxp1y1.y3.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y1.y3.4x$packStart(gtkLabel("MMM"),FALSE,FALSE)
form1.boxp1y1.y3.4x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y2.2y$add(form1.boxp1y1.y1.6x)
form1.boxp1y2.2y$add(form1.boxp1y1.y2.4x)
form1.boxp1y2.2y$add(form1.boxp1y1.y3.4x)
form1.framep1y2$add(form1.boxp1y2.2y)
form1.framep1y3 <- gtkFrame("NNN")
form1.boxp1y3.2y <- gtkVBox(FALSE,2)
### 1nd row ###
form1.boxp1y3.y1.6x <- gtkHBox(FALSE,6)
form1.boxp1y3.y1.6x$packStart(gtkLabel("OOO"),FALSE,FALSE)
form1.boxp1y3.y1.6x$packStart(gtkEntry(),TRUE,TRUE)
form1.boxp1y3.y1.6x$packStart(gtkLabel("PPP"),FALSE,FALSE)
form1.boxp1y3.y1.6x$packStart(gtkEntry(),FALSE,FALSE)
form1.boxp1y3.y1.6x$packStart(gtkLabel("QQQ"),FALSE,FALSE)
form1.boxp1y3.y1.6x$packStart(gtkEntry(),FALSE,FALSE)
### 2nd row ###
form1.boxp1y3.y2.2x <- gtkHBox(FALSE,2)
form1.boxp1y3.y2.2x$packStart(gtkCheckButton("RRR"),TRUE,TRUE)
form1.boxp1y3.y2.2x$packStart(gtkCheckButton("SSS"),TRUE,TRUE)
form1.boxp1y3.2y$add(form1.boxp1y3.y1.6x)
form1.boxp1y3.2y$add(form1.boxp1y3.y2.2x)
form1.framep1y3$add(form1.boxp1y3.2y)
form1.boxp1.y3$packStart(form1.framep1y1,FALSE,FALSE)
form1.boxp1.y3$packStart(form1.framep1y2,FALSE,FALSE)
form1.boxp1.y3$packStart(form1.framep1y3,FALSE,FALSE)
form1.boxp2.ud <- gtkVBox(FALSE,2)
form1.framep2f1 <- gtkFrame("TTT")
form1.framep2f2 <- gtkFrame("UUU")
form1.boxp2.ud$add(form1.framep2f1)
form1.boxp2.ud$add(form1.framep2f2)
form1.boxp3.ud <- gtkVBox(FALSE,1)
form1.framep3f1 <- gtkFrame("VVV")
form1.boxp3.ud$add(form1.framep3f1)
form1.boxp4.ud <- gtkVBox(FALSE,1)
form1.framep4f1 <- gtkFrame("WWW")
form1.boxp4.ud$add(form1.framep4f1)
form1.boxp5.ud <- gtkVBox(FALSE,1)
form1.framep5f1 <- gtkFrame("XXX")
form1.boxp5.ud$add(form1.framep5f1)
form1.notebook$add(form1.boxp1.y3)
form1.notebook$add(form1.boxp2.ud)
form1.notebook$add(form1.boxp3.ud)
form1.notebook$add(form1.boxp4.ud)
form1.notebook$add(form1.boxp5.ud)
forms.notebook$add(form1.notebook)
window.master$add(forms.notebook)
window.master$show()
我有幾個問題:
- 如何更改標籤的名字嗎? (我不能用第一頁,第二頁,第三頁隨處可見)
- 如何每行/幀之間添加間隔?
- 我想顯示從數據框信息到
gtkEntry
場,我想我需要給gtkEntry
場的標籤,我該怎麼辦呢?
謝謝。