raderde 1
raderde
Cannn6161 1
Cannn6161
noisiv 1
noisiv
Manwe Work 1
Manwe Work
Mt2Hizmet 1
Mt2Hizmet
melankolıa18 1
melankolıa18
romegames 1
romegames
Krutzo 1
Krutzo
shrpnl 1
shrpnl
Hikaye Ekle
Reklam vermek için turkmmo@gmail.com

Python Dynamic Table [QoL]

  • Konuyu başlatan Konuyu başlatan a✘seee;
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 10
  • Görüntüleme Görüntüleme 1K

a✘seee;

Manager
Telefon Numarası Onaylanmış Üye TC Kimlik Numarası Doğrulanmış Üye
TM Üye
Katılım
16 Eyl 2009
Konular
123
Mesajlar
2,377
Çözüm
25
Online süresi
1mo 5d
Reaksiyon Skoru
1,255
Altın Konu
0
Başarım Puanı
304
MmoLira
8,568
DevLira
-19
Ticaret - 0%
0   0   0

ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ HEMEN TIKLA!

hkQguIgfR4-TuEf4aeDxdw.png

[CODE lang="python" title="ui.py"]class Table(Window):
def __init__(self, width, head_height, colors):
Window.__init__(self, "UI")
self.width = width
self.head_height = head_height
self.table_height = head_height
self.colors = colors
self.row_heights = []
self.__children = {}
self.SetSize(width, head_height)
def __del__(self):
Window.__del__(self)
def Destroy(self):
self.__children = {}
def CreateTitleBar(self):
self.__children["title_base"] = MakeWindow(Bar(), self, ["not_pick"], (0,0), self.colors[1], "", (self.width, self.head_height))
self.__children["title_tl"] = MakeWindow(Line(), self, ["not_pick"], (0,0), self.colors[0], "", (self.width, 0))
self.__children["title_bl"] = MakeWindow(Line(), self, ["not_pick"], (0,self.head_height), self.colors[0], "", (self.width, 0))
self.__children["title_ll"] = MakeWindow(Line(), self, ["not_pick"], (0,0), self.colors[0], "", (0, self.head_height))
self.__children["title_rl"] = MakeWindow(Line(), self, ["not_pick"], (self.width,0), self.colors[0], "", (0, self.head_height))
def set_columns(self, headers, widths):
if len(headers) != len(widths): import dbg; dbg.LogBox("set_columns len(headers) != len(widths)"); return
self.headers = headers
self.widths = widths
self.CreateTitleBar()
count = len(headers)
cumulative_width = 0
for i in xrange(count):
wnd = MakeWindow(Window(), self.__children["title_base"], ["not_pick"], (cumulative_width,0), "", "", (self.widths, self.__children["title_base"].GetHeight()))
self.__children["title_w%d" % (i)] = wnd
self.__children["title_t%d" % (i)] = MakeWindow(TextLine(), wnd, ["not_pick"], (0,0), self.headers, "all:center")
if i < count - 1: self.__children["title_s%d" % (i)] = MakeWindow(Line(), wnd, ["not_pick"], (self.widths,0), self.colors[0], "", (0, self.__children["title_w%d" % (i)].GetHeight()))
cumulative_width += self.widths
def add_row(self, data, height):
if len(data) != len(self.widths): import dbg; dbg.LogBox("add_row: Data length does not match column count"); return
row_index = len(self.row_heights)
self.row_heights.append(height)
cumulative_width = 0
y_position = self.head_height + sum(self.row_heights[:row_index])
for i, value in enumerate(data):
wnd = MakeWindow(Window(), self, [], (cumulative_width, y_position), "", "", (self.widths, height))
self.__children["row_%d_b%d" % (row_index, i)] = MakeWindow(Bar(), wnd, ["not_pick"], (0,0), self.colors[2], "", (self.widths, height))
self.__children["row_%d_c%d" % (row_index, i)] = wnd
self.__children["row_%d_t%d" % (row_index, i)] = MakeWindow(TextLine(), wnd, [], (0, 0), str(value), "all:center")
if i < len(self.widths) - 1: self.__children["row_%d_s%d" % (row_index, i)] = MakeWindow(Line(), wnd, [], (self.widths, 0), self.colors[0], "", (0, height))
cumulative_width += self.widths
hline_y_position = self.head_height + sum(self.row_heights[:row_index + 1])
self.__children["row_%d_hline" % (row_index)] = MakeWindow(Line(), self, [], (0, hline_y_position), self.colors[0], "", (self.width, 0))
self.table_height = self.head_height + sum(self.row_heights)
self.SetSize(self.width, self.table_height)
self.__children["title_ll"].SetSize(0, self.table_height)
self.__children["title_rl"].SetSize(0, self.table_height)

def MakeWindow(window, parent, windowFlags, windowPos, windowArgument = "", windowPositionRule = "", windowSize = (-1, -1), windowFontName = -1, windowColor = 0, windowIsOutline = False):
if parent: window.SetParent(parent)
for flag in windowFlags: window.AddFlag(flag)
window.SetPosition(*windowPos)
if windowSize != (-1, -1): window.SetSize(*windowSize)
if windowColor != 0:
if isinstance(window, TextLine): window.SetPackedFontColor(windowColor)
if windowIsOutline:
if isinstance(window, TextLine): window.SetOutline()
if windowArgument:
if isinstance(window, TextLine):
if windowFontName != -1: window.SetFontName(windowFontName)
window.SetText(windowArgument)
elif isinstance(window, NumberLine):
window.SetNumber(windowArgument)
elif isinstance(window, Button) or isinstance(window, RadioButton) or isinstance(window, ToggleButton):
if isinstance(windowArgument, list):
window.SetUpVisual(windowArgument[0])
window.SetOverVisual(windowArgument[1] if len(windowArgument) >= 2 else windowArgument[0])
window.SetDownVisual(windowArgument[2] if len(windowArgument) >= 3 else windowArgument[0])
if len(windowArgument) == 4: window.SetDisableVisual(windowArgument[3])
elif isinstance(window, ExpandedImageBox) or isinstance(window, ImageBox):
window.LoadImage(windowArgument if windowArgument.find("gr2") == -1 else "icon/item/27995.tga")
elif isinstance(window, Line) or isinstance(window, Bar) or isinstance(window, Box):
window.SetColor(windowArgument)
if windowPositionRule:
splitList = windowPositionRule.split(":")
if len(splitList) == 2:
(type, mode) = (splitList[0], splitList[1])
if type == "all":
window.SetHorizontalAlignCenter()
window.SetVerticalAlignCenter()
window.SetWindowHorizontalAlignCenter()
window.SetWindowVerticalAlignCenter()
elif type == "horizontal":
if isinstance(window, TextLine):
if mode == "center": window.SetHorizontalAlignCenter()
elif mode == "right": window.SetHorizontalAlignRight()
elif mode == "left": window.SetHorizontalAlignLeft()
else:
if mode == "center": window.SetWindowHorizontalAlignCenter()
elif mode == "right": window.SetWindowHorizontalAlignRight()
elif mode == "left": window.SetWindowHorizontalAlignLeft()
elif type == "vertical":
if isinstance(window, TextLine):
if mode == "center": window.SetVerticalAlignCenter()
elif mode == "top": window.SetVerticalAlignTop()
elif mode == "bottom": window.SetVerticalAlignBottom()
else:
if mode == "top": window.SetWindowVerticalAlignTop()
elif mode == "center": window.SetWindowVerticalAlignCenter()
elif mode == "bottom": window.SetWindowVerticalAlignBottom()
window.Show()
return window[/CODE]

Örnek kullanım;

Python:
tableS = ui.Table(190, 26, [0xff746653, 0xff231811, 0x804b3f29])
tableS.SetPosition(0,0)
tableS.set_columns(["Nesne", "Olasılık"], [150, 40])
tableS.add_row(["abc", "%100"], 34)
tableS.Show()
 
Güzel paylaşım, eline sağlık
 
Eline sağlık teşekkürler. ^^
 
paylaşım için teşekkürler yararlı
 
Paylaşımın için teşekkürler
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst