AX菜单,form,table

本文介绍了一个使用递归方法构建多级菜单系统的实现方案。通过遍历节点并根据节点属性生成相应的菜单项,包括处理菜单项的类型、名称及显示文本等关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

class recursion{
    treeNode            childNode,menuitemNode;
    treeNode            fields,tables,LastTree,items;
    treenodeIterator    it, itFld,itlast,itmenu,menuFld;
    real                 layer,_count;
    ktl_formName        ktl_formName;
    label               label_gb,label_us,label_gb1,label_us1;


    
public static void main(args _args){
    recursion1 recursion
=new recursion1();
    recursion.init();
    }


    
public void init(){
    Str     _name;
    xInfo xInfo 
= new xInfo();

    treeNode t 
= xInfo.rootNode().AOTfindChild("Menus");
    it 
= t.AOTiterator();
    childnode
=it.next();
    layer
=1;
    
//delete_from ktl_formname;
    while(childnode)   {
        _name
= findProperty(childnode.AOTgetProperties(),'label');
       
// print   childnode.treeNodeName(),     "***";
       
// print num2str(layer,1,0,0,0);
      
// print _name;pause;


        itfld
=childnode.AOTiterator();
        itlast 
= t.AOTfindChild(childnode.treeNodeName()).AOTiterator();

       
// this.recursion2(layer,childnode,itlast,childnode.treeNodeName(),childnode.AOTchildNodeCount());

        
this.recursion(_name,layer,childnode,itlast,childnode.treeNodeName(),childnode.AOTchildNodeCount());
        layer
++;
        childnode
=it.next();

    }

  }


   
public void recursion(Str _label,real _layer,treeNode _ChildNode,treeNodeIterator _itfld,Str nodeName,int countNode)
{
        
int      mark;
        
int      i;
        str      formtype;
        str      formname;
        str      formlabel;
        str      menu_label ;

        xInfo    Info2;

        info2 
= new xInfo();

        childnode
=_childnode;
        i
=_layer*10;
        
//print int2str(_layer)+nodename+'---'; //主菜单

        ktl_FormName.clear();
        ktl_formname.ID
= num2str(layer,1,0,0,0);
        ktl_formname.ID_str
=num2str(_layer,1,0,0,0)+'*';
        ktl_FormName.Menu_class
='***';
        label_gb
=new label('en-gb');
        ktl_FormName.Form_cn
=label_gb.extractString(_label);
        label_us
=new label('en-us');
        ktl_FormName.Form_us
=label_us.extractString(_label);
        
//print  ktl_FormName.Form_cn,'--',ktl_FormName.Form_us;  pause;
        ktl_FormName.insert();

        _count
=countNode;

        fields
=_itfld.next();

        
while(fields){
             
--_count;
             i
++;
             mark
=fields.AOTchildNodeCount();
             
if(mark){

                 
this.recursion(findProperty(fields.AOTgetProperties(),"label"),i,childNode,fields.AOTiterator(),fields.treeNodeName(),fields.AOTchildNodeCount());

             }
  else {
              
//  print int2str(i)+fields.treeNodeName();   //Form 显示名称

                formtype
=findProperty(fields.AOTgetProperties(),"menuitemtype");     //Form 类型
               
// print   formtype;
                formname=findProperty(fields.AOTgetProperties(),"menuitemName");  //Form 名称
               
// print formname; //pause;

               
this.findForm1(formtype,formname,i,fields.treeNodeName());
                
if(_count==0)
                  i
=(i-(i mod 10))/10;
             }



            fields
=_itfld.next();
        }

}



void findForm1(Str _type,Str _name,real _layer,Str NodeName)
{
        Str     menu_class;
        Str     menu_object;
        str     menu_label;
        Info    xInfo1;
        treeNode t1;
        ;
        xInfo1 
= new xInfo();
         ttsbegin;

        
if(!_type || !_name){

             ktl_FormName.clear();

             ktl_FormName.Form_cn
=NodeName;
             ktl_formname.ID
= num2str(layer,1,0,0,0);
             ktl_formname.ID_str
=num2str(_layer,1,0,0,0);
             ktl_FormName.MenuItemName
=_name;
             ktl_FormName.MenuItemType
=_type;
             ktl_FormName.Menu_class
=menu_class;
             ktl_FormName.Menu_object
=menu_object;
             ktl_FormName.insert();
             
return;

        }
 else {


            t1 
= xInfo1.rootNode().AOTfindChild("Menu Items");
            itMenu 
= t1.AOTiterator();
            menuitemNode
=itmenu.next();
           
// print menuitemnode.treeNodeName();
            menufld=t1.AOTfindChild(_type).AOTiterator();

            items
=menufld.next();
            
while(items){
                
if(items.treeNodeName()==_name) {
                     menu_class
= findProperty(items.AOTgetProperties(),"Class");
                     menu_object
= findProperty(items.AOTgetProperties(),"Object");

                     ktl_FormName.clear();
                     
//ktl_FormName.Form_cn=NodeName;
                     ktl_formname.ID= num2str(layer,1,0,0,0);
                     ktl_formname.ID_str
=num2str(_layer,1,0,0,0);
                     ktl_FormName.MenuItemName
=_name;
                     ktl_FormName.MenuItemType
=_type;
                     ktl_FormName.Menu_class
=menu_class;
                     ktl_FormName.Menu_object
=menu_object;
                     menu_label
=findProperty(items.AOTgetProperties(),"label") ;
                    
//print formlabel;
                     label_gb1=new label('en-gb');
                     ktl_FormName.Form_cn
=label_gb1.extractString(menu_label);
                     label_us1
=new label('en-us');
                     ktl_FormName.Form_us
=label_us1.extractString(menu_label);
                      ktl_FormName.insert();
                    
// print  menu_class;
                    
// print  menu_object; pause;
                     return;
                }

                items
=menufld.next();
            }

        }

        ttscommit;

}







}
<think>好的,我需要解释如何在Matplotlib中使用ax.table来调整表格的位置。首先,我应该回顾一下ax.table的基本用法,然后说明如何移动表格的位置。可能涉及到的参数有loc、bbox等。需要详细说明这些参数的作用,以及如何通过设置bbox来调整表格的位置。可能还需要给出具体的代码示例,展示调整前后的效果。同时,要注意用户可能遇到的常见问题,比如坐标系的参考点,或者如何精确控制表格的位置。要确保语言简洁明了,步骤清晰,方便用户理解和应用。</think>在Matplotlib中,通过`ax.table`创建的表格默认会放置在坐标系的中央位置。若需要调整表格位置,可通过以下两种核心方法实现: --- ### 方法一:通过`loc`参数定位 `loc`参数支持9种预设位置(类似图例位置): ```python import matplotlib.pyplot as plt fig, ax = plt.subplots() table = ax.table(cellText=[['A','B'],['C','D']], loc='lower right', # 可选:'upper/lower/center' + 'left/right/center' colLabels=['Col1','Col2']) plt.show() ``` --- ### 方法二:通过`bbox`参数精确控制 `bbox`参数通过设置边界框([left, bottom, width, height])实现精准定位: ```python fig, ax = plt.subplots() table = ax.table(cellText=[['A','B'],['C','D']], colLabels=['Col1','Col2'], bbox=[0.5, 0.7, 0.3, 0.2]) # [左侧距离, 底部距离, 宽度, 高度] plt.show() ``` --- ### 关键细节说明 1. **坐标系参考**: - `bbox`使用**轴坐标系**(0~1相对坐标) - 若要使用**数据坐标系**,需先转换: ```python import matplotlib.transforms as transforms bbox = transforms.Bbox.from_bounds(x, y, width, height) # 数据坐标 ``` 2. **典型应用场景**: - 避免遮挡主图时:`bbox=[0.1, 0.8, 0.4, 0.15]`(右上角) - 多表格排列时:通过调整多个`bbox`的y坐标实现纵向堆叠 3. **样式优化组合技**: ```python table.auto_set_font_size(False) table.set_fontsize(10) table.scale(1.2, 1.5) # 调整单元格宽高缩放 ``` --- ### 效果对比示例 调整前(默认居中): ```python ax.table(..., loc='center') ``` 调整后(右上角定位): ```python ax.table(..., bbox=[0.65, 0.75, 0.3, 0.2]) ``` 实际应用中建议结合`plt.subplots_adjust()`调整子图边距,确保表格完整显示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值