require 'wx' require 'epony/models' require 'epony/database' require 'epony/client' module Pony # Application class. class WxApp < Wx::App attr :main attr :client # def on_init @client = Client.new @client.connect # connect to database # Get a new resources object xrc_file = File.join( File.dirname(__FILE__), 'epony.xrc' ) $xml = Wx::XmlResource.new(xrc_file) ctrls = [] xml = File.read(xrc_file) xml.scan(/name\=\"(.*?)\"/) do |n| ctrls << n end # Show the main frame. @main = MainFrame.new(self) ctrls.each do |c| name = c[0] instance_variable_set("@"+name, main.find_window_by_id(Wx::xrcid(name))) end setup_controls populate_grid(@client.videos) main.show(true) end # def setup_controls @grid_videos.append_cols(5) @grid_videos.append_rows(@client.limit) #@grid_videos = Wx::Grid.new(@panel_videos) #@grid_videos.create_grid(@client.limit, 5) #@grid_videos.set_col_size(0 , 650) #@grid_videos.set_col_minimal_width(0 , 650) @grid_videos.set_col_label_value( 0, "URL" ) @grid_videos.set_col_label_value( 1, "Size" ) @grid_videos.set_col_label_value( 2, "Category" ) @grid_videos.set_col_label_value( 3, "Cut Date" ) @grid_videos.set_col_label_value( 4, "Rating" ) #@grid_videos.set_col_size(2 , 110) #@grid_videos.set_col_minimal_width(2 , 110) @grid_videos.set_selection_mode(1) #choice = ::Wx::GridCellChoiceEditor.new(video_categories, true) #attrib = ::Wx::GridCellAttr.new #attrib.set_editor(choice) #@grid_videos.set_col_attr(2, attrib) end # def video_categories [ 'anal', 'oral' ] end # def populate_grid(videos) videos.each_with_index do |v, i| @grid_videos.set_cell_value(i, 0, v.href.to_s) @grid_videos.set_cell_value(i, 1, v.size.to_s) @grid_videos.set_cell_value(i, 2, v.category.to_s) @grid_videos.set_cell_value(i, 3, v.catdate.to_s) @grid_videos.set_cell_value(i, 4, v.rating.to_s) @grid_videos.set_read_only(i, 0, true) @grid_videos.set_read_only(i, 1, true) end end end class MainFrame < Wx::Frame def initialize(parent) super() $xml.load_frame_subclass(self, nil, 'frame_wxpony') end end end Pony::WxApp.new.main_loop()