doudao9896 2012-05-18 10:39
浏览 46

在php中调整GtkMessageDialog的大小

I need to resize a GtkMessageDialog in php to have enough space for long string (dont want a new line)!

Create it:

$dialog = new GtkMessageDialog($this->window, Gtk::DIALOG_MODAL, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, "");

Set the message output:

$message = "I NEED A LONG STRING TO DISPLAY IN THE DIALOG
"
$dialog->set_markup($message);

How its possible to adjust the dialog size? (the string should fit in one line)

Thanks and greets

leon22

  • 写回答

1条回答 默认 最新

  • duandeng1824 2012-05-20 22:10
    关注

    If I am correct you do not want to use new lines in order to increase the height of the dialog window.

    There is no difference how to do it, it is the same as with all other widgets, just use the set_size_request method. Also whenever you have such problem just tell php to get what methods are there avaiable.

    So for this example you would use this to get all methods:

    file_put_contents("out.txt",print_r(get_class_methods($dialog),true));
    

    This is a full example that set the size as you want it:

    <?php
    $window = new GtkWindow();
    $window->set_size_request(400, 600);
    $window->connect_simple('destroy', array('Gtk','main_quit'));
    
    $message = '<b>DO I NEED</b> A LONG STRING TO <b><span foreground="blue"> '.
    "DISPLAY IN THE DIALOG?</span></b>
    ";
    
    $dialog = new GtkMessageDialog($window, Gtk::DIALOG_MODAL, 
    Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, null); 
    
    $dialog->set_size_request(600,400);
    $dialog->set_markup($message);
    
    $answer = $dialog->run();
    $dialog->destroy(); 
    
    if ($answer == Gtk::RESPONSE_YES) 
        echo "So I need it.";
    else if ($answer == Gtk::RESPONSE_NO) 
        echo "I see, I don't need it.";
    else 
        echo "Choose something.";
    
    $window->show_all();
    Gtk::main();
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大